1515# specific language governing permissions and limitations
1616# under the License.
1717
18- from selenium .common .exceptions import (ElementNotInteractableException ,
18+ from selenium .common .exceptions import (ElementClickInterceptedException ,
19+ ElementNotInteractableException ,
1920 ElementNotSelectableException ,
2021 ElementNotVisibleException ,
2122 ErrorInResponseException ,
23+ InsecureCertificateException ,
24+ InvalidCoordinatesException ,
2225 InvalidElementStateException ,
26+ InvalidSessionIdException ,
2327 InvalidSelectorException ,
2428 ImeNotAvailableException ,
2529 ImeActivationFailedException ,
30+ InvalidArgumentException ,
31+ InvalidCookieDomainException ,
32+ JavascriptException ,
2633 MoveTargetOutOfBoundsException ,
34+ NoSuchCookieException ,
2735 NoSuchElementException ,
2836 NoSuchFrameException ,
2937 NoSuchWindowException ,
3038 NoAlertPresentException ,
39+ ScreenshotException ,
40+ SessionNotCreatedException ,
3141 StaleElementReferenceException ,
3242 TimeoutException ,
43+ UnableToSetCookieException ,
3344 UnexpectedAlertPresentException ,
45+ UnknownMethodException ,
3446 WebDriverException )
3547
3648try :
@@ -52,7 +64,6 @@ class ErrorCode(object):
5264 ELEMENT_NOT_VISIBLE = [11 , 'element not visible' ]
5365 INVALID_ELEMENT_STATE = [12 , 'invalid element state' ]
5466 UNKNOWN_ERROR = [13 , 'unknown error' ]
55- ELEMENT_NOT_INTERACTABLE = ["element not interactable" ]
5667 ELEMENT_IS_NOT_SELECTABLE = [15 , 'element not selectable' ]
5768 JAVASCRIPT_ERROR = [17 , 'javascript error' ]
5869 XPATH_LOOKUP_ERROR = [19 , 'invalid selector' ]
@@ -67,9 +78,21 @@ class ErrorCode(object):
6778 IME_NOT_AVAILABLE = [30 , 'ime not available' ]
6879 IME_ENGINE_ACTIVATION_FAILED = [31 , 'ime engine activation failed' ]
6980 INVALID_SELECTOR = [32 , 'invalid selector' ]
81+ SESSION_NOT_CREATED = [33 , 'session not created' ]
7082 MOVE_TARGET_OUT_OF_BOUNDS = [34 , 'move target out of bounds' ]
7183 INVALID_XPATH_SELECTOR = [51 , 'invalid selector' ]
7284 INVALID_XPATH_SELECTOR_RETURN_TYPER = [52 , 'invalid selector' ]
85+
86+ ELEMENT_NOT_INTERACTABLE = [60 , 'element not interactable' ]
87+ INSECURE_CERTIFICATE = ['insecure certificate' ]
88+ INVALID_ARGUMENT = [61 , 'invalid argument' ]
89+ INVALID_COORDINATES = ['invalid coordinates' ]
90+ INVALID_SESSION_ID = ['invalid session id' ]
91+ NO_SUCH_COOKIE = [62 , 'no such cookie' ]
92+ UNABLE_TO_CAPTURE_SCREEN = [63 , 'unable to capture screen' ]
93+ ELEMENT_CLICK_INTERCEPTED = [64 , 'element click intercepted' ]
94+ UNKNOWN_METHOD = ['unknown method exception' ]
95+
7396 METHOD_NOT_ALLOWED = [405 , 'unsupported operation' ]
7497
7598
@@ -136,9 +159,9 @@ def check_response(self, response):
136159 elif status in ErrorCode .ELEMENT_NOT_INTERACTABLE :
137160 exception_class = ElementNotInteractableException
138161 elif status in ErrorCode .INVALID_COOKIE_DOMAIN :
139- exception_class = WebDriverException
162+ exception_class = InvalidCookieDomainException
140163 elif status in ErrorCode .UNABLE_TO_SET_COOKIE :
141- exception_class = WebDriverException
164+ exception_class = UnableToSetCookieException
142165 elif status in ErrorCode .TIMEOUT :
143166 exception_class = TimeoutException
144167 elif status in ErrorCode .SCRIPT_TIMEOUT :
@@ -155,6 +178,26 @@ def check_response(self, response):
155178 exception_class = ImeActivationFailedException
156179 elif status in ErrorCode .MOVE_TARGET_OUT_OF_BOUNDS :
157180 exception_class = MoveTargetOutOfBoundsException
181+ elif status in ErrorCode .JAVASCRIPT_ERROR :
182+ exception_class = JavascriptException
183+ elif status in ErrorCode .SESSION_NOT_CREATED :
184+ exception_class = SessionNotCreatedException
185+ elif status in ErrorCode .INVALID_ARGUMENT :
186+ exception_class = InvalidArgumentException
187+ elif status in ErrorCode .NO_SUCH_COOKIE :
188+ exception_class = NoSuchCookieException
189+ elif status in ErrorCode .UNABLE_TO_CAPTURE_SCREEN :
190+ exception_class = ScreenshotException
191+ elif status in ErrorCode .ELEMENT_CLICK_INTERCEPTED :
192+ exception_class = ElementClickInterceptedException
193+ elif status in ErrorCode .INSECURE_CERTIFICATE :
194+ exception_class = InsecureCertificateException
195+ elif status in ErrorCode .INVALID_COORDINATES :
196+ exception_class = InvalidCoordinatesException
197+ elif status in ErrorCode .INVALID_SESSION_ID :
198+ exception_class = InvalidSessionIdException
199+ elif status in ErrorCode .UNKNOWN_METHOD :
200+ exception_class = UnknownMethodException
158201 else :
159202 exception_class = WebDriverException
160203 if value == '' or value is None :
0 commit comments