-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
[🐛 Bug]: [py] Mypy error - WebDriverWait.driver has attribute #15693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@MarcelWilson, thank you for creating this issue. We will troubleshoot it as soon as we can. Selenium Triage Team: remember to follow the Triage Guide |
Not surprising. I just ran our Mypy configuration across the codebase and we currently have 120 errors in 30 files! :) If by chance you are interested in cleaning up our type checking, a PR would be very welcomed (If not, I'll get to it eventually). You can run the Mypy job with:
|
This issue is looking for contributors. Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested. |
For the larger issue: #15697 |
I wouldn't mind giving it a go. The question then becomes about approach. Is it wise to expose the sessionid in WebElement? |
You need access to it from whichever class the I don't have the code in front of me at the moment, but... Is |
Under the hood, WebDriverWait needs a selenium/py/selenium/webdriver/support/wait.py Lines 134 to 146 in 255749b
However, it also accepts passing in selenium/py/selenium/webdriver/support/expected_conditions.py Lines 222 to 228 in 255749b
The only real issue here is when I see a couple of possibilities here:
if driver:
...
elif element:
... My hunch is the first approach makes the most sense (also has the smallest code change). But I fear this opinion may be biased as a user. |
I tried to submit a PR with the code change but it appears to have been automatically closed. I'm not sure I understand the objection. Maybe you can do something with the submission. |
I just re-opened your PR... Our bot is a little aggressive with closing things :) I'll review it later today. Thanks. |
When I close something instead of letting a bot do it, I'm mean 😂 |
Description
The following error from mypy occurs for
WebDriverWait.__repr__
error: Item "WebElement" of the upper bound "WebDriver | WebElement" of type variable "D" has no attribute "session_id" [union-attr]
Explanation:
If you pass a WebElement into
WebDriverWait
, the repr will not be able to properly access thesession_id
attribute. Mypy is detecting this.My guess is there likely needs to be additional logic to access
driver
fromWebElement.parent
in those cases, orsession_id
needs to be exposed as an attribute ofWebElement
.Reproducible Code
The text was updated successfully, but these errors were encountered: