Skip to content

Commit b0807bc

Browse files
author
AutomatedTester
committed
Allow error handling to handle both current errors and w3c errors
1 parent 4efa15d commit b0807bc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

py/selenium/webdriver/remote/errorhandler.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,22 @@ def check_response(self, response):
8787
8888
:Raises: If the response contains an error message.
8989
"""
90-
status = response['status']
91-
if status == ErrorCode.SUCCESS:
90+
status = response.get('status', None)
91+
if status is None or status == ErrorCode.SUCCESS:
9292
return
93+
94+
value = None
95+
message = response.get("message", "")
96+
screen = response.get("screen", "")
97+
stacktrace = None
98+
if isinstance(status, int):
99+
value_json = response.get('value', None)
100+
if value_json and isinstance(value_json, basestring):
101+
import json
102+
value = json.loads(value_json)
103+
status = value['status']
104+
message = value['message']
105+
93106
exception_class = ErrorInResponseException
94107
if status in ErrorCode.NO_SUCH_ELEMENT:
95108
exception_class = NoSuchElementException

0 commit comments

Comments
 (0)