Skip to content

Commit 6a05791

Browse files
authored
Merge pull request #3124 from seleniumbase/refactor-uc-mode-and-js-waits
Refactor UC Mode and JS waits
2 parents 5212bdb + 9b2597b commit 6a05791

17 files changed

+102
-38
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ pytest test_coffee_cart.py --trace
651651
--binary-location=PATH # (Set path of the Chromium browser binary to use.)
652652
--driver-version=VER # (Set the chromedriver or uc_driver version to use.)
653653
--sjw # (Skip JS Waits for readyState to be "complete" or Angular to load.)
654+
--wfa # (Wait for AngularJS to be done loading after specific web actions.)
654655
--pls=PLS # (Set pageLoadStrategy on Chrome: "normal", "eager", or "none".)
655656
--headless # (Run tests in headless mode. The default arg on Linux OS.)
656657
--headless2 # (Use the new headless mode, which supports extensions.)

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

examples/hack_the_planet.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,11 @@ def test_all_your_base_are_belong_to_us(self):
131131
self.highlight("section.crayons-card", loops=7, scroll=False)
132132

133133
self.open("https://azure.microsoft.com/en-us/services/playfab/")
134-
self.remove_elements('div[role="dialog"]')
135134
self.set_text_content("h1", aybabtu)
136135
self.set_text_content('a[aria-label*="Try Azure"]', ayb)
137136
self.set_text_content('a[aria-label*="Sign in to"]', abtu)
137+
self.remove_elements('div[role="dialog"]')
138+
self.remove_elements('[aria-label*="Microsoft Survey"]')
138139
self.highlight("h1", loops=6, scroll=False)
139140
self.highlight('a[aria-label*="Try Azure"]', loops=4, scroll=False)
140141
self.highlight('a[aria-label*="Sign in to"]', loops=6, scroll=False)
@@ -308,15 +309,6 @@ def test_all_your_base_are_belong_to_us(self):
308309
self.highlight("h1", loops=6, scroll=False)
309310
self.highlight("input#search", loops=8, scroll=False)
310311

311-
self.open("https://www.atlassian.com/software/jira")
312-
self.set_text_content('a[href*="jira/pricing"]', ayb)
313-
self.set_text_content('a[href*="jira/enterprise"]', abtu)
314-
self.set_text_content('a[href="/software/jira/features"]', "")
315-
self.set_text_content("h1", aybabtu)
316-
self.highlight('a[href*="jira/pricing"]', loops=5, scroll=False)
317-
self.highlight('a[href*="jira/enterprise"]', loops=6, scroll=False)
318-
self.highlight("h1", loops=8, scroll=False)
319-
320312
self.open("https://status.iboss.com/ibcloud/app/cloudStatus.html")
321313
self.wait_for_element_clickable('div[translate*="cloudStatus"]')
322314
self.set_text_content('div[translate*="cloudStatus"]', ayb)

examples/raw_ahrefs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
sb.uc_open_with_reconnect(url) # The bot-check is later
88
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
99
sb.reconnect(0.1)
10-
sb.uc_click(submit_button, reconnect_time=4)
10+
sb.uc_click(submit_button, reconnect_time=3.25)
1111
sb.uc_gui_click_captcha()
12-
sb.wait_for_text_not_visible("Checking", timeout=12)
12+
sb.wait_for_text_not_visible("Checking", timeout=11.5)
1313
sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
1414
sb.highlight('a:contains("Top 100 backlinks")')
1515
sb.set_messenger_theme(location="bottom_center")

examples/raw_nopecha.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
with SB(uc=True, test=True) as sb:
44
sb.uc_open_with_reconnect("nopecha.com/demo/turnstile", 3.2)
5-
sb.uc_gui_click_captcha("#example-container0")
5+
if sb.is_element_visible("#example-container0"):
6+
sb.uc_gui_click_captcha("#example-container0")
67
sb.uc_gui_click_captcha("#example-container5")
78
sb.sleep(3)

examples/test_geolocation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_geolocation(self):
3939
)
4040
self.open("https://www.openstreetmap.org/")
4141
self.click("span.geolocate")
42-
self.assert_url_contains("48.87645/2.26340")
42+
self.assert_url_contains("48.876450/2.263400")
4343
self.save_screenshot_to_logs()
4444
if self.headed:
4545
self.sleep(4)

help_docs/customizing_test_runs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ pytest my_first_test.py --settings-file=custom_settings.py
142142
--binary-location=PATH # (Set path of the Chromium browser binary to use.)
143143
--driver-version=VER # (Set the chromedriver or uc_driver version to use.)
144144
--sjw # (Skip JS Waits for readyState to be "complete" or Angular to load.)
145+
--wfa # (Wait for AngularJS to be done loading after specific web actions.)
145146
--pls=PLS # (Set pageLoadStrategy on Chrome: "normal", "eager", or "none".)
146147
--headless # (Run tests in headless mode. The default arg on Linux OS.)
147148
--headless2 # (Use the new headless mode, which supports extensions.)

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mkdocs dependencies for generating the seleniumbase.io website
22
# Minimum Python version: 3.8 (for generating docs only)
33

4-
regex>=2024.7.24
4+
regex>=2024.9.11
55
pymdown-extensions>=10.9
66
pipdeptree>=2.23.3
77
python-dateutil>=2.8.2

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.30.4"
2+
__version__ = "4.30.5"

seleniumbase/behave/behave_sb.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
-D binary-location=PATH (Set path of the Chromium browser binary to use.)
4343
-D driver-version=VER (Set the chromedriver or uc_driver version to use.)
4444
-D sjw (Skip JS Waits for readyState to be "complete" or Angular to load.)
45+
-D wfa (Wait for AngularJS to be done loading after specific web actions.)
4546
-D pls=PLS (Set pageLoadStrategy on Chrome: "normal", "eager", or "none".)
4647
-D headless (Run tests in headless mode. The default arg on Linux OS.)
4748
-D headless2 (Use the new headless mode, which supports extensions.)
@@ -588,6 +589,10 @@ def get_configured_sb(context):
588589
if low_key in ["sjw", "skip-js-waits", "skip_js_waits"]:
589590
settings.SKIP_JS_WAITS = True
590591
continue
592+
# Handle: -D wfa / wait-for-angularjs / wait_for_angularjs
593+
if low_key in ["wfa", "wait-for-angularjs", "wait_for_angularjs"]:
594+
settings.WAIT_FOR_ANGULARJS = True
595+
continue
591596
# Handle: -D visual-baseline / visual_baseline
592597
if low_key in ["visual-baseline", "visual_baseline"]:
593598
sb.visual_baseline = True
@@ -889,6 +894,16 @@ def get_configured_sb(context):
889894
# If the port is "443", the protocol is "https"
890895
if str(sb.port) == "443":
891896
sb.protocol = "https"
897+
if (
898+
(sb.enable_ws is None and sb.disable_ws is None)
899+
or (sb.disable_ws is not None and not sb.disable_ws)
900+
or (sb.enable_ws is not None and sb.enable_ws)
901+
):
902+
sb.enable_ws = True
903+
sb.disable_ws = False
904+
else:
905+
sb.enable_ws = False
906+
sb.disable_ws = True
892907
if sb.window_size:
893908
window_size = sb.window_size
894909
if window_size.count(",") != 1:

0 commit comments

Comments
 (0)