1717"""Exceptions that may happen in all the webdriver code."""
1818
1919from collections .abc import Sequence
20- from typing import Any , Optional
20+ from typing import Any
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 [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
30+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = 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 [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
76+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
7777 ) -> None :
7878 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #nosuchelementexception"
7979
@@ -111,7 +111,7 @@ class StaleElementReferenceException(WebDriverException):
111111 """
112112
113113 def __init__ (
114- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
114+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
115115 ) -> None :
116116 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #staleelementreferenceexception"
117117
@@ -134,10 +134,10 @@ class UnexpectedAlertPresentException(WebDriverException):
134134
135135 def __init__ (
136136 self ,
137- msg : Optional [ Any ] = None ,
138- screen : Optional [ str ] = None ,
139- stacktrace : Optional [ Sequence [str ]] = None ,
140- alert_text : Optional [ str ] = None ,
137+ msg : Any | None = None ,
138+ screen : str | None = None ,
139+ stacktrace : Sequence [str ] | None = None ,
140+ alert_text : str | None = None ,
141141 ) -> None :
142142 super ().__init__ (msg , screen , stacktrace )
143143 self .alert_text = alert_text
@@ -161,7 +161,7 @@ class ElementNotVisibleException(InvalidElementStateException):
161161 """
162162
163163 def __init__ (
164- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
164+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
165165 ) -> None :
166166 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #elementnotvisibleexception"
167167
@@ -172,7 +172,7 @@ class ElementNotInteractableException(InvalidElementStateException):
172172 """Thrown when element interactions will hit another element due to paint order."""
173173
174174 def __init__ (
175- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
175+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
176176 ) -> None :
177177 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #elementnotinteractableexception"
178178
@@ -213,7 +213,7 @@ class InvalidSelectorException(WebDriverException):
213213 """
214214
215215 def __init__ (
216- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
216+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
217217 ) -> None :
218218 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #invalidselectorexception"
219219
@@ -252,7 +252,7 @@ class ElementClickInterceptedException(WebDriverException):
252252 """Thrown when element click fails because another element obscures it."""
253253
254254 def __init__ (
255- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
255+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
256256 ) -> None :
257257 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #elementclickinterceptedexception"
258258
@@ -271,7 +271,7 @@ class InvalidSessionIdException(WebDriverException):
271271 """Thrown when the given session id is not in the list of active sessions."""
272272
273273 def __init__ (
274- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
274+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
275275 ) -> None :
276276 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #invalidsessionidexception"
277277
@@ -282,7 +282,7 @@ class SessionNotCreatedException(WebDriverException):
282282 """A new session could not be created."""
283283
284284 def __init__ (
285- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
285+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
286286 ) -> None :
287287 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } #sessionnotcreatedexception"
288288
@@ -297,7 +297,7 @@ class NoSuchDriverException(WebDriverException):
297297 """Raised when driver is not specified and cannot be located."""
298298
299299 def __init__ (
300- self , msg : Optional [ Any ] = None , screen : Optional [ str ] = None , stacktrace : Optional [ Sequence [str ]] = None
300+ self , msg : Any | None = None , screen : str | None = None , stacktrace : Sequence [str ] | None = None
301301 ) -> None :
302302 with_support = f"{ msg } ; { SUPPORT_MSG } { ERROR_URL } /driver_location"
303303
0 commit comments