[🐛 Bug]: incorrect type hint to WebDriverWait init
What happened?
A recent PR added some type hints to WebDriverWait: https://github.com/SeleniumHQ/selenium/pull/13070/files
The hint here in the init definition says that the driver argument should be of type WebDriver: https://github.com/SeleniumHQ/selenium/blob/1c9e702b8686f04d9fe69824f3bdd171fa523df1/py/selenium/webdriver/support/wait.py#L38
But the docstring says that WebElement is also a permissible type for this argument: https://github.com/SeleniumHQ/selenium/blob/1c9e702b8686f04d9fe69824f3bdd171fa523df1/py/selenium/webdriver/support/wait.py#L46
The workings of the class also allow for web elements as an init input, so the type hint is incorrect. Static type checking (for example with mypy) will fail even for functional and type-safe code that uses a wait with a web element.
How can we reproduce the issue?
'''example.py'''
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Firefox()
driver.get("http://example.com")
heading1 = driver.find_element(By.TAG_NAME, 'h1')
WebDriverWait(heading1, 10)
driver.quit()
Relevant log output
>> mypy example.py
example.py:11: error: Argument 1 to "WebDriverWait" has incompatible type "WebElement"; expected "WebDriver" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Operating System
Ubuntu
Selenium version
Python 4.15.0
What are the browser(s) and version(s) where you see this issue?
not applicable
What are the browser driver(s) and version(s) where you see this issue?
not applicable
Are you using Selenium Grid?
No response
@luketudge, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
Can you make a PR? Thanks.
Can you make a PR? Thanks.
Ok. Is here: https://github.com/SeleniumHQ/selenium/pull/13088
here's another one #13108 also checking parameter type of until and until_not
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.