Skip to content

Commit e34928f

Browse files
committed
Change default settings for AngularJS waits
1 parent 70806d5 commit e34928f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

examples/custom_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
# Called after self.click(selector), NOT element.click()
4949
WAIT_FOR_RSC_ON_CLICKS = False
5050
# Wait for AngularJS calls to complete after various browser actions.
51-
WAIT_FOR_ANGULARJS = True
51+
WAIT_FOR_ANGULARJS = False
5252
# Skip ALL calls to wait_for_ready_state_complete() and wait_for_angularjs().
5353
SKIP_JS_WAITS = False
5454

seleniumbase/config/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# Called after self.click(selector), NOT element.click()
7676
WAIT_FOR_RSC_ON_CLICKS = False
7777
# Wait for AngularJS calls to complete after various browser actions.
78-
WAIT_FOR_ANGULARJS = True
78+
WAIT_FOR_ANGULARJS = False
7979
# Skip all calls to wait_for_ready_state_complete() and wait_for_angularjs().
8080
SKIP_JS_WAITS = False
8181

seleniumbase/fixtures/js_utils.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,28 @@ def wait_for_ready_state_complete(driver, timeout=settings.LARGE_TIMEOUT):
4848
return False # readyState stayed "interactive" (Not "complete")
4949

5050

51-
def execute_async_script(driver, script, timeout=settings.EXTREME_TIMEOUT):
51+
def execute_async_script(driver, script, timeout=settings.LARGE_TIMEOUT):
5252
driver.set_script_timeout(timeout)
5353
return driver.execute_async_script(script)
5454

5555

5656
def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs):
5757
if hasattr(settings, "SKIP_JS_WAITS") and settings.SKIP_JS_WAITS:
5858
return
59+
try:
60+
# This closes pop-up alerts
61+
driver.execute_script("")
62+
except Exception:
63+
pass
64+
if hasattr(driver, "_is_using_uc") and driver._is_using_uc:
65+
# Calling AngularJS waits may make UC Mode detectable.
66+
# Instead, pause for a brief moment, and then return.
67+
time.sleep(0.007)
68+
return
5969
if not settings.WAIT_FOR_ANGULARJS:
6070
return
6171
if timeout == settings.MINI_TIMEOUT:
62-
timeout = settings.MINI_TIMEOUT / 2.0
63-
72+
timeout = settings.MINI_TIMEOUT / 4.0
6473
NG_WRAPPER = (
6574
"%(prefix)s"
6675
"var $elm=document.querySelector("
@@ -84,15 +93,10 @@ def wait_for_angularjs(driver, timeout=settings.LARGE_TIMEOUT, **kwargs):
8493
"handler": handler,
8594
"suffix": suffix,
8695
}
87-
try:
88-
# This closes any pop-up alerts (otherwise the next part fails)
89-
driver.execute_script("")
90-
except Exception:
91-
pass
9296
try:
9397
execute_async_script(driver, script, timeout=timeout)
9498
except Exception:
95-
time.sleep(0.05)
99+
time.sleep(0.0456)
96100

97101

98102
def convert_to_css_selector(selector, by=By.CSS_SELECTOR):

0 commit comments

Comments
 (0)