From d10164ce14db73d606e4e87f32fee2a9527ab811 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 26 Jul 2024 14:31:50 -0400 Subject: [PATCH 1/3] Handle update to form turnstiles --- seleniumbase/core/browser_launcher.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/seleniumbase/core/browser_launcher.py b/seleniumbase/core/browser_launcher.py index 0a22610272e..b6ebadc647f 100644 --- a/seleniumbase/core/browser_launcher.py +++ b/seleniumbase/core/browser_launcher.py @@ -812,6 +812,16 @@ def _uc_gui_click_captcha( and driver.is_element_present("div.spacer div[style]") ): frame = "div.spacer div[style]" + elif ( + ( + driver.is_element_present('[name*="cf-turnstile-"]') + or driver.is_element_present('[id*="cf-turnstile-"]') + ) + and driver.is_element_present( + 'form div div[style*="margin"][style*="padding"]' + ) + ): + frame = 'form div div[style*="margin"][style*="padding"]' elif ( frame != "iframe" and driver.is_element_present( @@ -1017,7 +1027,7 @@ def uc_gui_handle_cf(driver, frame="iframe"): time.sleep(0.02) active_element_css = js_utils.get_active_element_css(driver) if ( - active_element_css == "div.cf-turnstile-wrapper" + active_element_css.startswith("div.cf-turnstile") or active_element_css.startswith("div#PYMIw2") ): found_checkbox = True From e2f69b7e3cefdac3ea1e42fe7e3ff424718c1ce4 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 26 Jul 2024 14:38:22 -0400 Subject: [PATCH 2/3] Update examples --- examples/raw_ahrefs.py | 7 ++++--- examples/raw_form_turnstile.py | 2 +- examples/raw_games.py | 10 ++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/raw_ahrefs.py b/examples/raw_ahrefs.py index 5fbc4451542..f09cf78d322 100644 --- a/examples/raw_ahrefs.py +++ b/examples/raw_ahrefs.py @@ -4,10 +4,11 @@ url = "https://ahrefs.com/website-authority-checker" input_field = 'input[placeholder="Enter domain"]' submit_button = 'span:contains("Check Authority")' - sb.driver.uc_open_with_reconnect(url, 2) # The bot-check is later + sb.uc_open_with_reconnect(url, 2) # The bot-check is later sb.type(input_field, "github.com/seleniumbase/SeleniumBase") - sb.driver.reconnect(0.1) - sb.driver.uc_click(submit_button, reconnect_time=4) + sb.reconnect(0.1) + sb.uc_click(submit_button, reconnect_time=4) + sb.uc_gui_click_captcha() sb.wait_for_text_not_visible("Checking", timeout=10) sb.highlight('p:contains("github.com/seleniumbase/SeleniumBase")') sb.highlight('a:contains("Top 100 backlinks")') diff --git a/examples/raw_form_turnstile.py b/examples/raw_form_turnstile.py index 8791a572c0a..8e7bf6b7085 100644 --- a/examples/raw_form_turnstile.py +++ b/examples/raw_form_turnstile.py @@ -12,7 +12,7 @@ sb.click('span:contains("9:00 PM")') sb.highlight_click('input[value="AR"] + span') sb.click('input[value="cc"] + span') - sb.scroll_to("div.cf-turnstile-wrapper") + sb.scroll_to('div[class*="cf-turnstile"]') sb.uc_gui_handle_cf() sb.highlight("img#captcha-success", timeout=3) sb.highlight_click('button:contains("Request & Pay")') diff --git a/examples/raw_games.py b/examples/raw_games.py index e5684f2ce94..27b4185e1f7 100644 --- a/examples/raw_games.py +++ b/examples/raw_games.py @@ -3,13 +3,11 @@ with SB(uc=True, test=True, disable_csp=True) as sb: url = "https://steamdb.info/" - sb.driver.uc_open_with_reconnect(url, 3) - sb.uc_click("a.header-login span", 4) - if not sb.is_text_visible("Sign in", "button#js-sign-in"): - sb.driver.uc_open_with_reconnect(url, 3) - sb.uc_click("a.header-login span", 4) + sb.uc_open_with_reconnect(url, 3) + sb.uc_click("a.header-login span", 3) + sb.uc_gui_click_captcha() sb.assert_text("Sign in", "button#js-sign-in", timeout=3) - sb.driver.uc_click("button#js-sign-in", 2) + sb.uc_click("button#js-sign-in", 2) sb.highlight("div.page_content form") sb.highlight('button:contains("Sign in")', scroll=False) sb.set_messenger_theme(location="top_center") From 7374d4bcd9141dd84af470c3e9904452c79178c8 Mon Sep 17 00:00:00 2001 From: Michael Mintz Date: Fri, 26 Jul 2024 14:38:54 -0400 Subject: [PATCH 3/3] Version 4.29.3 --- seleniumbase/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seleniumbase/__version__.py b/seleniumbase/__version__.py index d1b98bd2a16..29c985bf92f 100755 --- a/seleniumbase/__version__.py +++ b/seleniumbase/__version__.py @@ -1,2 +1,2 @@ # seleniumbase package -__version__ = "4.29.2" +__version__ = "4.29.3"