File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1+ """An example of displaying Shadow DOM inside HTML"""
2+ from seleniumbase import sb_cdp
3+
4+ url = "https://seleniumbase.io/apps/turnstile"
5+ sb = sb_cdp .Chrome (url )
6+ element = sb .find_element ("div.cf-turnstile div" )
7+ html_with_shadow_dom = element .get_html ()
8+ print (html_with_shadow_dom )
9+ text_to_find = "Widget containing a Cloudflare security challenge"
10+ sb .assert_true (text_to_find in html_with_shadow_dom )
11+ sb .solve_captcha ()
12+ sb .assert_element ("img#captcha-success" , timeout = 3 )
13+ sb .set_messenger_theme (location = "top_left" )
14+ sb .post_message ("SeleniumBase wasn't detected" , duration = 3 )
Original file line number Diff line number Diff line change 1- """To handle alerts in CDP Mode, reconnect and use WebDriver ."""
1+ """An example of handling alerts in CDP Mode."""
22from seleniumbase import SB
33
44with SB (uc = True , test = True ) as sb :
55 url = "https://the-internet.herokuapp.com/javascript_alerts"
66 sb .activate_cdp_mode (url )
7- sb .reconnect ()
87 sb .cdp .gui_click_element ('button[onclick="jsAlert()"]' )
98 sb .sleep (1 )
10- sb .accept_alert ()
9+ sb .uc_gui_press_key ( " \n " ) # Accept Alert
1110 sb .sleep (1 )
1211 sb .cdp .gui_click_element ('button[onclick="jsConfirm()"]' )
1312 sb .sleep (1 )
14- sb .dismiss_alert ()
13+ sb .uc_gui_press_key ( "ESC" ) # Dismiss Alert
1514 sb .sleep (1 )
1615 sb .cdp .gui_click_element ('button[onclick="jsPrompt()"]' )
1716 sb .sleep (1 )
You can’t perform that action at this time.
0 commit comments