Update examples
This commit is contained in:
parent
8621dfeef6
commit
fda2ffe865
|
@ -5,7 +5,7 @@ driver = Driver(uc=True, log_cdp=True)
|
|||
try:
|
||||
url = "seleniumbase.io/apps/turnstile"
|
||||
driver.uc_open_with_reconnect(url, 2)
|
||||
driver.uc_gui_handle_cf()
|
||||
driver.uc_gui_handle_captcha()
|
||||
driver.sleep(3)
|
||||
pprint(driver.get_log("performance"))
|
||||
finally:
|
||||
|
|
|
@ -13,7 +13,7 @@ with SB(uc=True, test=True) as sb:
|
|||
sb.highlight_click('input[value="AR"] + span')
|
||||
sb.click('input[value="cc"] + span')
|
||||
sb.scroll_to('div[class*="cf-turnstile"]')
|
||||
sb.uc_gui_handle_cf()
|
||||
sb.uc_gui_handle_captcha()
|
||||
sb.highlight("img#captcha-success", timeout=3)
|
||||
sb.highlight_click('button:contains("Request & Pay")')
|
||||
sb.highlight("img#submit-success")
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
"""
|
||||
UC Mode now has uc_gui_click_cf(), which uses PyAutoGUI.
|
||||
An incomplete UserAgent forces CAPTCHA-solving on macOS.
|
||||
"""
|
||||
import sys
|
||||
from seleniumbase import SB
|
||||
|
||||
# An incomplete UserAgent forces CAPTCHA-solving on macOS
|
||||
agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/126.0.0.0"
|
||||
if "linux" in sys.platform or "win32" in sys.platform:
|
||||
agent = None # Use the default UserAgent
|
||||
|
@ -12,7 +9,7 @@ if "linux" in sys.platform or "win32" in sys.platform:
|
|||
with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
|
||||
url = "https://gitlab.com/users/sign_in"
|
||||
sb.uc_open_with_reconnect(url, 4)
|
||||
sb.uc_gui_click_cf() # Ready if needed!
|
||||
sb.uc_gui_click_captcha() # Only if needed
|
||||
sb.assert_element('label[for="user_login"]')
|
||||
sb.assert_element('input[data-testid*="username"]')
|
||||
sb.assert_element('input[data-testid*="password"]')
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
"""
|
||||
UC Mode now has uc_gui_handle_cf(), which uses PyAutoGUI.
|
||||
An incomplete User-Agent forces CAPTCHA-solving on macOS.
|
||||
"""
|
||||
import sys
|
||||
from seleniumbase import SB
|
||||
|
||||
# An incomplete UserAgent forces CAPTCHA-solving on macOS
|
||||
agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/126.0.0.0"
|
||||
if "linux" in sys.platform or "win32" in sys.platform:
|
||||
agent = None # Use the default UserAgent
|
||||
|
@ -12,7 +9,7 @@ if "linux" in sys.platform or "win32" in sys.platform:
|
|||
with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
|
||||
url = "https://gitlab.com/users/sign_in"
|
||||
sb.uc_open_with_reconnect(url, 4)
|
||||
sb.uc_gui_handle_cf() # Ready if needed!
|
||||
sb.uc_gui_handle_captcha() # Only if needed
|
||||
sb.assert_element('label[for="user_login"]')
|
||||
sb.assert_element('input[data-testid*="username"]')
|
||||
sb.assert_element('input[data-testid*="password"]')
|
||||
|
|
|
@ -3,7 +3,15 @@ from seleniumbase import SB
|
|||
with SB(uc=True, test=True) as sb:
|
||||
url = "https://seleniumbase.io/apps/recaptcha"
|
||||
sb.uc_open_with_reconnect(url)
|
||||
sb.uc_gui_click_captcha()
|
||||
sb.uc_gui_handle_captcha() # Try with TAB + SPACEBAR
|
||||
sb.assert_element("img#captcha-success", timeout=3)
|
||||
sb.set_messenger_theme(location="top_left")
|
||||
sb.post_message("SeleniumBase wasn't detected", duration=3)
|
||||
|
||||
with SB(uc=True, test=True) as sb:
|
||||
url = "https://seleniumbase.io/apps/recaptcha"
|
||||
sb.uc_open_with_reconnect(url)
|
||||
sb.uc_gui_click_captcha() # Try with PyAutoGUI Click
|
||||
sb.assert_element("img#captcha-success", timeout=3)
|
||||
sb.set_messenger_theme(location="top_left")
|
||||
sb.post_message("SeleniumBase wasn't detected", duration=3)
|
||||
|
|
|
@ -13,7 +13,7 @@ class CDPTests(BaseCase):
|
|||
)
|
||||
|
||||
def click_turnstile_and_verify(sb):
|
||||
sb.uc_gui_handle_cf()
|
||||
sb.uc_gui_handle_captcha()
|
||||
sb.assert_element("img#captcha-success", timeout=3)
|
||||
sb.highlight("img#captcha-success", loops=8)
|
||||
|
||||
|
|
Loading…
Reference in New Issue