1717"""Exceptions that may happen in all the webdriver code."""
1818
1919from collections .abc import Sequence
20- from typing import Optional
20+ from typing import Any , Optional
2121
2222SUPPORT_MSG = "For documentation on this error, please visit:"
2323ERROR_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
0 commit comments