Skip to content

Commit bdf8772

Browse files
committed
Update CDP Mode examples
1 parent 25d6ca8 commit bdf8772

28 files changed

+113
-101
lines changed

examples/cdp_mode/raw_ahrefs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
submit_button = 'span:contains("Check Authority")'
77
sb.activate_cdp_mode(url) # The bot-check is later
88
sb.type(input_field, "github.com/seleniumbase/SeleniumBase")
9-
sb.cdp.scroll_down(36)
9+
sb.scroll_down(36)
1010
sb.click(submit_button)
1111
sb.sleep(1)
12-
sb.uc_gui_click_captcha()
12+
sb.solve_captcha()
1313
sb.sleep(3)
1414
sb.wait_for_text_not_visible("Checking", timeout=15)
1515
sb.click_if_visible('button[data-cky-tag="close-button"]')

examples/cdp_mode/raw_bestwestern.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
url = "https://www.bestwestern.com/en_US.html"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.5)
7-
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
7+
sb.click_if_visible(".onetrust-close-btn-handler")
88
sb.sleep(1)
9-
sb.cdp.click("input#destination-input")
9+
sb.click("input#destination-input")
1010
sb.sleep(2)
1111
location = "Palm Springs, CA, USA"
12-
sb.cdp.press_keys("input#destination-input", location)
12+
sb.press_keys("input#destination-input", location)
1313
sb.sleep(1)
14-
sb.cdp.click("ul#google-suggestions li")
14+
sb.click("ul#google-suggestions li")
1515
sb.sleep(1)
16-
sb.cdp.click("button#btn-modify-stay-update")
16+
sb.click("button#btn-modify-stay-update")
1717
sb.sleep(4)
18-
sb.cdp.click("label#available-label")
18+
sb.click("label#available-label")
1919
sb.sleep(2.5)
2020
print("Best Western Hotels in %s:" % location)
21-
summary_details = sb.cdp.get_text("#summary-details-column")
21+
summary_details = sb.get_text("#summary-details-column")
2222
dates = summary_details.split("DESTINATION")[-1]
2323
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
2424
dates = dates.replace(" ", " ")
2525
print("(Dates: %s)" % dates)
26-
flip_cards = sb.cdp.select_all(".flipCard")
26+
flip_cards = sb.select_all(".flipCard")
2727
for i, flip_card in enumerate(flip_cards):
2828
hotel = flip_card.query_selector(".hotelName")
2929
price = flip_card.query_selector(".priceSection")

examples/cdp_mode/raw_browserscan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
sb.sleep(1)
77
sb.cdp.flash("Test Results", duration=4)
88
sb.sleep(1)
9-
sb.cdp.assert_element('strong:contains("Normal")')
9+
sb.assert_element('strong:contains("Normal")')
1010
sb.cdp.flash('strong:contains("Normal")', duration=4, pause=4)

examples/cdp_mode/raw_cdp_copilot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
sb.sleep(1.1)
1717
sb.click('button[data-testid="submit-button"]')
1818
sb.sleep(2.5)
19-
sb.gui_click_captcha()
20-
sb.sleep(2.5)
21-
sb.gui_click_captcha()
19+
sb.solve_captcha()
2220
sb.sleep(3.5)
21+
sb.solve_captcha()
22+
sb.sleep(2.5)
2323
stop_button = '[data-testid="stop-button"]'
2424
thumbs_up = 'button[data-testid*="-thumbs-up-"]'
2525
sb.wait_for_element_absent(stop_button, timeout=50)

examples/cdp_mode/raw_cdp_with_sb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
print(sb.get_title())
2424
print("************")
2525
for i in range(8):
26-
sb.cdp.scroll_down(50)
26+
sb.scroll_down(50)
2727
sb.sleep(0.2)
2828
cards = sb.select_all('span[data-automation*="product-list-card"]')
2929
for card in cards:

examples/cdp_mode/raw_consecutive_c.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
url = "https://sms-man.com/login"
66
sb.activate_cdp_mode(url)
77
sb.sleep(2.2)
8-
sb.uc_gui_click_captcha()
9-
sb.sleep(2.6)
10-
sb.uc_gui_click_captcha()
8+
if not sb.is_element_present('input[name="email"]'):
9+
sb.solve_captcha()
10+
sb.sleep(1)
11+
sb.wait_for_element('[name="email"]', timeout=3)
12+
sb.sleep(2)
13+
sb.solve_captcha()
1114
sb.sleep(2)

examples/cdp_mode/raw_copilot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
sb.sleep(1.1)
1818
sb.click('button[data-testid="submit-button"]')
1919
sb.sleep(2.5)
20-
sb.uc_gui_click_captcha()
21-
sb.sleep(2.5)
22-
sb.uc_gui_click_captcha()
20+
sb.solve_captcha()
2321
sb.sleep(3.5)
22+
sb.solve_captcha()
23+
sb.sleep(2.5)
2424
stop_button = '[data-testid="stop-button"]'
2525
thumbs_up = 'button[data-testid*="-thumbs-up-"]'
2626
sb.wait_for_element_absent(stop_button, timeout=50)

examples/cdp_mode/raw_gitlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with SB(uc=True, test=True, locale="en") as sb:
44
url = "https://gitlab.com/users/sign_in"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2.2)
6+
sb.sleep(2)
77
sb.solve_captcha()
88
# (The rest is for testing and demo purposes)
99
sb.assert_text("Username", '[for="user_login"]', timeout=3)

examples/cdp_mode/raw_glassdoor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
url = "https://www.glassdoor.com/Reviews/index.htm"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.2)
7-
sb.uc_gui_click_captcha()
7+
sb.solve_captcha()
88
sb.highlight('[data-test="global-nav-glassdoor-logo"]')
99
sb.highlight('[data-test="site-header-companies"]')
1010
sb.highlight('[data-test="search-button"]')

examples/cdp_mode/raw_indeed.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
search_box = "input#company-search"
77
if not sb.is_element_present(search_box):
88
sb.sleep(2)
9-
sb.uc_gui_click_captcha()
9+
sb.solve_captcha()
1010
sb.sleep(1)
1111
company = "NASA Jet Propulsion Laboratory"
1212
sb.click(search_box)
@@ -18,14 +18,14 @@
1818
sb.sleep(1)
1919
if not sb.is_element_present(name_header):
2020
sb.sleep(2)
21-
sb.uc_gui_click_captcha()
21+
sb.solve_captcha()
2222
sb.sleep(1)
23-
sb.cdp.highlight(name_header)
23+
sb.highlight(name_header)
2424
sb.sleep(1)
2525
sb.cdp.highlight('h2:contains("About the company")')
2626
sb.sleep(1)
2727
for i in range(10):
28-
sb.cdp.scroll_down(12)
28+
sb.scroll_down(12)
2929
sb.sleep(0.14)
3030
info = sb.find_element('[data-testid="AboutSection-section"]')
3131
soup = sb.get_beautiful_soup(info.get_html()).get_text("\n").strip()

0 commit comments

Comments
 (0)