Skip to content

Commit 185ad89

Browse files
reverted frame exception obj, changed type from str to Any in the common exception file
1 parent e274a60 commit 185ad89

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

py/selenium/common/exceptions.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"""Exceptions that may happen in all the webdriver code."""
1818

1919
from collections.abc import Sequence
20-
from typing import Optional
20+
from typing import Any, Optional
2121

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

2929
def __init__(
30-
self, msg: Optional[str] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
30+
self, msg: Optional[Any] = None, screen: Optional[str] = None, stacktrace: Optional[Sequence[str]] = None
3131
) -> None:
3232
super().__init__()
3333
self.msg = msg
@@ -73,7 +73,7 @@ class NoSuchElementException(WebDriverException):
7373
"""
7474

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

@@ -112,7 +112,7 @@ class StaleElementReferenceException(WebDriverException):
112112
"""
113113

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

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

138138
def __init__(
139139
self,
140-
msg: Optional[str] = None,
140+
msg: Optional[Any] = None,
141141
screen: Optional[str] = None,
142142
stacktrace: Optional[Sequence[str]] = None,
143143
alert_text: Optional[str] = None,
@@ -166,7 +166,7 @@ class ElementNotVisibleException(InvalidElementStateException):
166166
"""
167167

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

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

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

@@ -225,7 +225,7 @@ class InvalidSelectorException(WebDriverException):
225225
"""
226226

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

@@ -267,7 +267,7 @@ class ElementClickInterceptedException(WebDriverException):
267267
clicked."""
268268

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

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

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

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

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

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

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

py/selenium/webdriver/remote/switch_to.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,13 @@ def frame(self, frame_reference: Union[str, int, WebElement]) -> None:
8080
driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
8181
"""
8282
if isinstance(frame_reference, str):
83-
frame_name = frame_reference
8483
try:
8584
frame_reference = self._driver.find_element(By.ID, frame_reference)
8685
except NoSuchElementException:
8786
try:
8887
frame_reference = self._driver.find_element(By.NAME, frame_reference)
8988
except NoSuchElementException as exc:
90-
raise NoSuchFrameException(frame_name) from exc
89+
raise NoSuchFrameException(frame_reference) from exc
9190

9291
self._driver.execute(Command.SWITCH_TO_FRAME, {"id": frame_reference})
9392

0 commit comments

Comments
 (0)