Skip to content

Commit 63d571a

Browse files
carlosgcamposlmtierney
authored andcommitted
[py] correctly handle additional data in unexpected alter error for w3c drivers (#5416)
The WebDriver spec defines an optional "data" field for error objects and annotated unexpected alert open error which includes a "text" field in the error additional data object. https://w3c.github.io/webdriver/webdriver-spec.html#dfn-error-data https://w3c.github.io/webdriver/webdriver-spec.html#dfn-user-prompt-handler
1 parent ba2fa95 commit 63d571a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

py/selenium/webdriver/remote/errorhandler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,13 @@ def check_response(self, response):
232232
pass
233233
if exception_class == ErrorInResponseException:
234234
raise exception_class(response, message)
235-
elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
236-
raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
235+
elif exception_class == UnexpectedAlertPresentException:
236+
alert_text = None
237+
if 'data' in value:
238+
alert_text = value['data'].get('text')
239+
elif 'alert' in value:
240+
alert_text = value['alert'].get('text')
241+
raise exception_class(message, screen, stacktrace, alert_text)
237242
raise exception_class(message, screen, stacktrace)
238243

239244
def _value_or_default(self, obj, key, default):

0 commit comments

Comments
 (0)