Skip to content

Commit 266bdc1

Browse files
committed
Improve error-handling around alerts
1 parent ec8e172 commit 266bdc1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

seleniumbase/fixtures/js_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def wait_for_ready_state_complete(driver, timeout=settings.EXTREME_TIMEOUT):
2525
stop_ms = start_ms + (timeout * 1000.0)
2626
for x in range(int(timeout * 10)):
2727
shared_utils.check_if_time_limit_exceeded()
28+
try:
29+
# If there's an alert, skip
30+
driver.switch_to.alert
31+
return
32+
except Exception:
33+
# If there's no alert, continue
34+
pass
2835
try:
2936
ready_state = driver.execute_script("return document.readyState")
3037
except WebDriverException:
@@ -49,6 +56,13 @@ def execute_async_script(driver, script, timeout=settings.EXTREME_TIMEOUT):
4956

5057

5158
def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs):
59+
try:
60+
# If there's an alert, skip
61+
driver.switch_to.alert
62+
return
63+
except Exception:
64+
# If there's no alert, continue
65+
pass
5266
if not settings.WAIT_FOR_ANGULARJS:
5367
return
5468

0 commit comments

Comments
 (0)