Closed
Description
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}")>'