Skip to content

Commit 0e8b32f

Browse files
committed
Update CDP Mode examples
1 parent a756d91 commit 0e8b32f

6 files changed

Lines changed: 28 additions & 13 deletions

File tree

examples/cdp_mode/playwright/raw_indeed_sync.py

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

44
sb = sb_cdp.Chrome()
55
sb.open("https://www.indeed.com/companies/search")
6+
sb.sleep(2)
7+
sb.solve_captcha()
8+
sb.sleep(1)
69
endpoint_url = sb.get_endpoint_url()
710

811
with sync_playwright() as p:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from seleniumbase import SB
22

3-
with SB(uc=True, test=True, guest=True) as sb:
3+
with SB(uc=True, test=True, incognito=True) as sb:
44
url = "https://www.cloudflare.com/login"
55
sb.activate_cdp_mode(url)
66
sb.wait_for_element('div[data-testid*="challenge-widget"]')
7-
sb.sleep(2)
7+
sb.sleep(2.5)
88
sb.solve_captcha()
99
sb.sleep(3)

examples/cdp_mode/raw_glassdoor.py

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

3-
with SB(uc=True, test=True, ad_block=True) as sb:
3+
with SB(uc=True, test=True, incognito=True) as sb:
44
url = "https://www.glassdoor.com/Reviews/index.htm"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(1.5)
6+
sb.sleep(2.1)
77
sb.solve_captcha()
8-
sb.sleep(0.5)
8+
sb.sleep(0.6)
99
sb.highlight('[data-test="global-nav-glassdoor-logo"]')
1010
sb.highlight('[data-test="site-header-companies"]')
1111
sb.highlight('[data-test="search-button"]')
1212
sb.highlight('[data-test="sign-in-button"]')
1313
sb.highlight('[data-test="company-search-autocomplete"]')
14+
sb.press_keys("#employer-autocomplete", "NASA Goddard\n")
15+
sb.sleep(0.5)
16+
sb.click('button[data-role-variant="primary"] span:contains("Search")')
17+
sb.sleep(2)
18+
sb.click('[aria-label*="NASA"] img')
19+
sb.sleep(2)
20+
print(sb.get_page_title())
21+
sb.save_as_pdf_to_logs()
22+
sb.save_page_source_to_logs()
23+
sb.save_screenshot_to_logs()
24+
print("Logs have been saved to: ./latest_logs/")

examples/cdp_mode/raw_indeed.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
with SB(uc=True, test=True) as sb:
44
url = "https://www.indeed.com/companies/search"
55
sb.activate_cdp_mode(url)
6+
sb.sleep(2)
67
search_box = "input#company-search"
78
if not sb.is_element_present(search_box):
8-
sb.sleep(2)
99
sb.solve_captcha()
1010
sb.sleep(1)
1111
company = "NASA Jet Propulsion Laboratory"
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""An example of clicking at custom CAPTCHA coordinates."""
22
from seleniumbase import SB
33

4-
with SB(uc=True, test=True, locale="en") as sb:
4+
with SB(uc=True, test=True, incognito=True) as sb:
55
url = "https://secure.indeed.com/auth"
66
sb.activate_cdp_mode(url)
7-
sb.sleep(1)
7+
sb.sleep(1.8)
8+
sb.solve_captcha()
9+
sb.sleep(1.8)
810
sb.type('input[type="email"]', "test@test.com")
9-
sb.sleep(1)
11+
sb.sleep(1.5)
1012
sb.click('button[type="submit"]')
11-
sb.sleep(3.5)
12-
selector = 'div[class*="pass-Captcha"]'
13-
sb.click_with_offset(selector, 32, 42)
13+
sb.sleep(3.2)
14+
sb.solve_captcha()
1415
sb.sleep(4.5)

examples/cdp_mode/raw_planetmc.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, guest=True) as sb:
44
url = "www.planetminecraft.com/account/sign_in/"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2)
6+
sb.sleep(3)
77
sb.solve_captcha()
88
sb.wait_for_element_absent("input[disabled]")
99
sb.sleep(2)

0 commit comments

Comments
 (0)