Skip to content

Commit e1a2b53

Browse files
committed
[py]: Tidy some webelement.py and simplify branched logic
1 parent a8026c1 commit e1a2b53

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

py/selenium/webdriver/remote/webelement.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,13 @@ def find_elements(self, by=By.ID, value=None) -> list[WebElement]:
445445
"""
446446
if by == By.ID:
447447
by = By.CSS_SELECTOR
448-
value = '[id="%s"]' % value
448+
value = f'[id="{value}"]'
449449
elif by == By.CLASS_NAME:
450450
by = By.CSS_SELECTOR
451-
value = ".%s" % value
451+
value = f".{value}"
452452
elif by == By.NAME:
453453
by = By.CSS_SELECTOR
454-
value = '[name="%s"]' % value
454+
value = f'[name="{value}"]'
455455

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

@@ -471,9 +471,8 @@ def _upload(self, filename):
471471
except WebDriverException as e:
472472
if "Unrecognized command: POST" in str(e):
473473
return filename
474-
elif "Command not found: POST " in str(e):
474+
if "Command not found: POST " in str(e):
475475
return filename
476-
elif '{"status":405,"value":["GET","HEAD","DELETE"]}' in str(e):
476+
if '{"status":405,"value":["GET","HEAD","DELETE"]}' in str(e):
477477
return filename
478-
else:
479-
raise
478+
raise

0 commit comments

Comments
 (0)