Skip to content

Commit 025572d

Browse files
authored
Merge pull request #2967 from seleniumbase/handle-form-captchas
Handle update to form turnstiles
2 parents 645b126 + 7374d4b commit 025572d

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
lines changed

examples/raw_ahrefs.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
url = "https://ahrefs.com/website-authority-checker"
55
input_field = 'input[placeholder="Enter domain"]'
66
submit_button = 'span:contains("Check Authority")'
7-
sb.driver.uc_open_with_reconnect(url, 2) # The bot-check is later
7+
sb.uc_open_with_reconnect(url, 2) # The bot-check is later
88
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
9-
sb.driver.reconnect(0.1)
10-
sb.driver.uc_click(submit_button, reconnect_time=4)
9+
sb.reconnect(0.1)
10+
sb.uc_click(submit_button, reconnect_time=4)
11+
sb.uc_gui_click_captcha()
1112
sb.wait_for_text_not_visible("Checking", timeout=10)
1213
sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")')
1314
sb.highlight('a:contains("Top 100 backlinks")')

examples/raw_form_turnstile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
sb.click('span:contains("9:00 PM")')
1313
sb.highlight_click('input[value="AR"] + span')
1414
sb.click('input[value="cc"] + span')
15-
sb.scroll_to("div.cf-turnstile-wrapper")
15+
sb.scroll_to('div[class*="cf-turnstile"]')
1616
sb.uc_gui_handle_cf()
1717
sb.highlight("img#captcha-success", timeout=3)
1818
sb.highlight_click('button:contains("Request & Pay")')

examples/raw_games.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33

44
with SB(uc=True, test=True, disable_csp=True) as sb:
55
url = "https://steamdb.info/"
6-
sb.driver.uc_open_with_reconnect(url, 3)
7-
sb.uc_click("a.header-login span", 4)
8-
if not sb.is_text_visible("Sign in", "button#js-sign-in"):
9-
sb.driver.uc_open_with_reconnect(url, 3)
10-
sb.uc_click("a.header-login span", 4)
6+
sb.uc_open_with_reconnect(url, 3)
7+
sb.uc_click("a.header-login span", 3)
8+
sb.uc_gui_click_captcha()
119
sb.assert_text("Sign in", "button#js-sign-in", timeout=3)
12-
sb.driver.uc_click("button#js-sign-in", 2)
10+
sb.uc_click("button#js-sign-in", 2)
1311
sb.highlight("div.page_content form")
1412
sb.highlight('button:contains("Sign in")', scroll=False)
1513
sb.set_messenger_theme(location="top_center")

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.29.2"
2+
__version__ = "4.29.3"

seleniumbase/core/browser_launcher.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,16 @@ def _uc_gui_click_captcha(
812812
and driver.is_element_present("div.spacer div[style]")
813813
):
814814
frame = "div.spacer div[style]"
815+
elif (
816+
(
817+
driver.is_element_present('[name*="cf-turnstile-"]')
818+
or driver.is_element_present('[id*="cf-turnstile-"]')
819+
)
820+
and driver.is_element_present(
821+
'form div div[style*="margin"][style*="padding"]'
822+
)
823+
):
824+
frame = 'form div div[style*="margin"][style*="padding"]'
815825
elif (
816826
frame != "iframe"
817827
and driver.is_element_present(
@@ -1017,7 +1027,7 @@ def uc_gui_handle_cf(driver, frame="iframe"):
10171027
time.sleep(0.02)
10181028
active_element_css = js_utils.get_active_element_css(driver)
10191029
if (
1020-
active_element_css == "div.cf-turnstile-wrapper"
1030+
active_element_css.startswith("div.cf-turnstile")
10211031
or active_element_css.startswith("div#PYMIw2")
10221032
):
10231033
found_checkbox = True

0 commit comments

Comments
 (0)