Skip to content

Commit de75ec6

Browse files
committed
Update examples
1 parent 4dcbf3c commit de75ec6

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

examples/raw_gui_click.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
UC Mode now has uc_gui_click_cf(), which uses PyAutoGUI.
3+
An incomplete UserAgent is used to force CAPTCHA-solving.
4+
"""
5+
import sys
6+
from seleniumbase import SB
7+
8+
agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/126.0.0.0"
9+
if "linux" in sys.platform:
10+
agent = None # Use the default UserAgent
11+
12+
with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
13+
url = "https://www.virtualmanager.com/en/login"
14+
sb.uc_open_with_reconnect(url, 4)
15+
sb.uc_gui_click_cf() # Ready if needed!
16+
sb.assert_element('input[name*="email"]')
17+
sb.assert_element('input[name*="login"]')
18+
sb.set_messenger_theme(location="bottom_center")
19+
sb.post_message("SeleniumBase wasn't detected!")

examples/raw_order_tickets.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from seleniumbase import SB
22

3-
with SB(uc=True, test=True, ad_block_on=True) as sb:
3+
with SB(uc=True, test=True, ad_block=True) as sb:
44
url = "https://www.thaiticketmajor.com/concert/"
5-
sb.driver.uc_open_with_reconnect(url, 6.111)
6-
sb.driver.uc_click("button.btn-signin", 4.1)
5+
sb.uc_open_with_reconnect(url, 6.111)
6+
sb.uc_click("button.btn-signin", 4.1)
77
sb.switch_to_frame('iframe[title*="Cloudflare"]')
8-
sb.assert_element("div#success svg#success-icon")
8+
if not sb.is_element_visible("svg#success-icon"):
9+
sb.uc_gui_handle_cf()
10+
sb.switch_to_frame('iframe[title*="Cloudflare"]')
11+
sb.assert_element("svg#success-icon")
912
sb.switch_to_default_content()
1013
sb.set_messenger_theme(location="top_center")
1114
sb.post_message("SeleniumBase wasn't detected!")

examples/raw_uc_mode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
with SB(uc=True, test=True) as sb:
55
url = "https://gitlab.com/users/sign_in"
6-
sb.driver.uc_open_with_reconnect(url, 3)
7-
if not sb.is_text_visible("Username", '[for="user_login"]'):
8-
sb.driver.uc_open_with_reconnect(url, 4)
6+
sb.uc_open_with_reconnect(url, 4)
7+
sb.uc_gui_click_cf()
98
sb.assert_text("Username", '[for="user_login"]', timeout=3)
109
sb.assert_element('label[for="user_login"]')
1110
sb.highlight('button:contains("Sign in")')

0 commit comments

Comments
 (0)