Skip to content

Commit cd911ed

Browse files
committed
Optimize wait_for_ready_state_complete()
1 parent 44b5809 commit cd911ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

seleniumbase/fixtures/js_utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@
1414
from seleniumbase.fixtures import shared_utils
1515

1616

17-
def wait_for_ready_state_complete(driver, timeout=settings.EXTREME_TIMEOUT):
17+
def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT):
1818
"""
1919
The DOM (Document Object Model) has a property called "readyState".
2020
When the value of this becomes "complete", page resources are considered
21-
fully loaded (although AJAX and other loads might still be happening).
21+
fully loaded (although AJAX and other loads might still be happening).
2222
This method will wait until document.readyState == "complete".
23+
This may be redundant, as methods already wait for page elements to load.
24+
If the timeout is exceeded, the test will still continue
25+
because readyState == "interactive" may be good enough.
26+
(Previously, tests would fail immediately if exceeding the timeout.)
2327
"""
2428
start_ms = time.time() * 1000.0
2529
stop_ms = start_ms + (timeout * 1000.0)
@@ -39,8 +43,7 @@ def wait_for_ready_state_complete(driver, timeout=settings.EXTREME_TIMEOUT):
3943
if now_ms >= stop_ms:
4044
break
4145
time.sleep(0.1)
42-
raise Exception(
43-
"Page elements never fully loaded after %s seconds!" % timeout)
46+
return False # readyState stayed "interactive" (Not "complete")
4447

4548

4649
def execute_async_script(driver, script, timeout=settings.EXTREME_TIMEOUT):

0 commit comments

Comments
 (0)