Skip to content

[馃悰 Bug]: [py] Mypy error - WebDriverWait.driver has attribute#15693

Description

@MarcelWilson

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 the session_id attribute. Mypy is detecting this.

    def __repr__(self):
        return f'<{type(self).__module__}.{type(self).__name__} (session="{self._driver.session_id}")>'

My guess is there likely needs to be additional logic to access driver from WebElement.parent in those cases, or session_id needs to be exposed as an attribute of WebElement.

Reproducible Code

def __repr__(self):
        return f'<{type(self).__module__}.{type(self).__name__} (session="{self._driver.session_id}")>'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-pyPython BindingsI-defectSomething is not working as intendedR-help wantedIssues looking for contributionsgood first issueGood first issue for new contributors to start with

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions