Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
bda34a7
fixed mypy errors in switch_to file and relative locator file
pallavigitwork Sep 8, 2025
c911b18
stored frame into another var and passed that in exception
pallavigitwork Sep 9, 2025
7288b92
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 9, 2025
e1af0c3
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 10, 2025
f9f7abd
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 11, 2025
673582d
Merge branch 'trunk' into Fix15697-5
cgoldberg Sep 15, 2025
06d3045
moved the bytype at module level, fixed the imports, reverted the ret…
pallavigitwork Sep 17, 2025
d2f22ce
reverted return type, moved bytype to module level, added by import
pallavigitwork Sep 17, 2025
712aeec
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 17, 2025
2139b51
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 18, 2025
afab8bf
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 19, 2025
e274a60
Merge branch 'trunk' into Fix15697-5
cgoldberg Sep 23, 2025
185ad89
reverted frame exception obj, changed type from str to Any in the com…
pallavigitwork Sep 24, 2025
f456910
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 27, 2025
01a88c8
Merge branch 'trunk' into Fix15697-5
pallavigitwork Sep 29, 2025
84c18ba
Merge branch 'trunk' into Fix15697-5
pallavigitwork Oct 3, 2025
a46a37a
Merge branch 'trunk' into Fix15697-5
pallavigitwork Oct 11, 2025
63f26eb
Merge branch 'trunk' into Fix15697-5
pallavigitwork Oct 14, 2025
0043264
Merge branch 'trunk' into Fix15697-5
pallavigitwork Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions py/selenium/common/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""Exceptions that may happen in all the webdriver code."""

from collections.abc import Sequence
from typing import Optional
from typing import Any, Optional

SUPPORT_MSG = "For documentation on this error, please visit:"
ERROR_URL = "https://www.selenium.dev/documentation/webdriver/troubleshooting/errors"
Expand All @@ -27,7 +27,7 @@ class WebDriverException(Exception):
"""Base webdriver exception."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
super().__init__()
self.msg = msg
Expand Down Expand Up @@ -73,7 +73,7 @@ class NoSuchElementException(WebDriverException):
"""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#nosuchelementexception"

Expand Down Expand Up @@ -112,7 +112,7 @@ class StaleElementReferenceException(WebDriverException):
"""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#staleelementreferenceexception"

Expand All @@ -137,7 +137,7 @@ class UnexpectedAlertPresentException(WebDriverException):

def __init__(
self,
msg: Optional[str] = None,
msg: Optional[Any] = None,
screen: Optional[str] = None,
stacktrace: Optional[Sequence[str]] = None,
alert_text: Optional[str] = None,
Expand Down Expand Up @@ -166,7 +166,7 @@ class ElementNotVisibleException(InvalidElementStateException):
"""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementnotvisibleexception"

Expand All @@ -178,7 +178,7 @@ class ElementNotInteractableException(InvalidElementStateException):
element will hit another element due to paint order."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementnotinteractableexception"

Expand Down Expand Up @@ -225,7 +225,7 @@ class InvalidSelectorException(WebDriverException):
"""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#invalidselectorexception"

Expand Down Expand Up @@ -267,7 +267,7 @@ class ElementClickInterceptedException(WebDriverException):
clicked."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#elementclickinterceptedexception"

Expand All @@ -288,7 +288,7 @@ class InvalidSessionIdException(WebDriverException):
meaning the session either does not exist or that it's not active."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#invalidsessionidexception"

Expand All @@ -299,7 +299,7 @@ class SessionNotCreatedException(WebDriverException):
"""A new session could not be created."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}#sessionnotcreatedexception"

Expand All @@ -315,7 +315,7 @@ class NoSuchDriverException(WebDriverException):
"""Raised when driver is not specified and cannot be located."""

def __init__(
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
) -> None:
with_support = f"{msg}; {SUPPORT_MSG} {ERROR_URL}/driver_location"

Expand Down
21 changes: 10 additions & 11 deletions py/selenium/webdriver/common/by.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

from typing import Literal, Optional

ByType = Literal["id", "xpath", "link text", "partial link text", "name", "tag name", "class name", "css selector"]


class By:
"""Set of supported locator strategies.
Expand Down Expand Up @@ -73,14 +75,14 @@ class By:
>>> element = driver.find_element(By.CSS_SELECTOR, "div.myElement")
"""

ID = "id"
XPATH = "xpath"
LINK_TEXT = "link text"
PARTIAL_LINK_TEXT = "partial link text"
NAME = "name"
TAG_NAME = "tag name"
CLASS_NAME = "class name"
CSS_SELECTOR = "css selector"
ID: ByType = "id"
XPATH: ByType = "xpath"
LINK_TEXT: ByType = "link text"
PARTIAL_LINK_TEXT: ByType = "partial link text"
NAME: ByType = "name"
TAG_NAME: ByType = "tag name"
CLASS_NAME: ByType = "class name"
CSS_SELECTOR: ByType = "css selector"

_custom_finders: dict[str, str] = {}

Expand All @@ -95,6 +97,3 @@ def get_finder(cls, name: str) -> Optional[str]:
@classmethod
def clear_custom_finders(cls) -> None:
cls._custom_finders.clear()


ByType = Literal["id", "xpath", "link text", "partial link text", "name", "tag name", "class name", "css selector"]