Skip to content

Commit b0909b3

Browse files
committed
Improve error-handling for "by"-selection
1 parent af8e11d commit b0909b3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

seleniumbase/fixtures/page_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ def recalculate_selector(selector, by, xp_ok=True):
114114
by = By.XPATH
115115
if by == "":
116116
by = By.CSS_SELECTOR
117+
if not is_valid_by(by):
118+
valid_by_options = [
119+
"css selector", "link text", "partial link text",
120+
"name", "xpath", "id", "tag name", "class name",
121+
]
122+
msg = "Choose a `by` from: %s." % valid_by_options
123+
raise Exception('Invalid `by`: "%s"\n%s' % (by, msg))
117124
return (selector, by)
118125

119126

0 commit comments

Comments
 (0)