Skip to content

Commit

Permalink
[py]: Tidy some webelement.py and simplify branched logic
Browse files Browse the repository at this point in the history
  • Loading branch information
symonk committed Oct 2, 2022
1 parent a8026c1 commit e1a2b53
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,13 @@ def find_elements(self, by=By.ID, value=None) -> list[WebElement]:
"""
if by == By.ID:
by = By.CSS_SELECTOR
value = '[id="%s"]' % value
value = f'[id="{value}"]'
elif by == By.CLASS_NAME:
by = By.CSS_SELECTOR
value = ".%s" % value
value = f".{value}"
elif by == By.NAME:
by = By.CSS_SELECTOR
value = '[name="%s"]' % value
value = f'[name="{value}"]'

return self._execute(Command.FIND_CHILD_ELEMENTS, {"using": by, "value": value})["value"]

Expand All @@ -471,9 +471,8 @@ def _upload(self, filename):
except WebDriverException as e:
if "Unrecognized command: POST" in str(e):
return filename
elif "Command not found: POST " in str(e):
if "Command not found: POST " in str(e):
return filename
elif '{"status":405,"value":["GET","HEAD","DELETE"]}' in str(e):
if '{"status":405,"value":["GET","HEAD","DELETE"]}' in str(e):
return filename
else:
raise
raise

0 comments on commit e1a2b53

Please sign in to comment.