Improve error-handling for "by"-selection
This commit is contained in:
parent
af8e11dd50
commit
b0909b3bec
|
@ -114,6 +114,13 @@ def recalculate_selector(selector, by, xp_ok=True):
|
||||||
by = By.XPATH
|
by = By.XPATH
|
||||||
if by == "":
|
if by == "":
|
||||||
by = By.CSS_SELECTOR
|
by = By.CSS_SELECTOR
|
||||||
|
if not is_valid_by(by):
|
||||||
|
valid_by_options = [
|
||||||
|
"css selector", "link text", "partial link text",
|
||||||
|
"name", "xpath", "id", "tag name", "class name",
|
||||||
|
]
|
||||||
|
msg = "Choose a `by` from: %s." % valid_by_options
|
||||||
|
raise Exception('Invalid `by`: "%s"\n%s' % (by, msg))
|
||||||
return (selector, by)
|
return (selector, by)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue