Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions examples/cdp_mode/playwright/raw_indeed_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

sb = sb_cdp.Chrome()
sb.open("https://www.indeed.com/companies/search")
sb.sleep(2)
sb.solve_captcha()
sb.sleep(1)
endpoint_url = sb.get_endpoint_url()

with sync_playwright() as p:
Expand Down
4 changes: 2 additions & 2 deletions examples/cdp_mode/raw_cf_captcha.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from seleniumbase import SB

with SB(uc=True, test=True, guest=True) as sb:
with SB(uc=True, test=True, incognito=True) as sb:
url = "https://www.cloudflare.com/login"
sb.activate_cdp_mode(url)
sb.wait_for_element('div[data-testid*="challenge-widget"]')
sb.sleep(2)
sb.sleep(2.5)
sb.solve_captcha()
sb.sleep(3)
17 changes: 14 additions & 3 deletions examples/cdp_mode/raw_glassdoor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
from seleniumbase import SB

with SB(uc=True, test=True, ad_block=True) as sb:
with SB(uc=True, test=True, incognito=True) as sb:
url = "https://www.glassdoor.com/Reviews/index.htm"
sb.activate_cdp_mode(url)
sb.sleep(1.5)
sb.sleep(2.1)
sb.solve_captcha()
sb.sleep(0.5)
sb.sleep(0.6)
sb.highlight('[data-test="global-nav-glassdoor-logo"]')
sb.highlight('[data-test="site-header-companies"]')
sb.highlight('[data-test="search-button"]')
sb.highlight('[data-test="sign-in-button"]')
sb.highlight('[data-test="company-search-autocomplete"]')
sb.press_keys("#employer-autocomplete", "NASA Goddard\n")
sb.sleep(0.5)
sb.click('button[data-role-variant="primary"] span:contains("Search")')
sb.sleep(2)
sb.click('[aria-label*="NASA"] img')
sb.sleep(2)
print(sb.get_page_title())
sb.save_as_pdf_to_logs()
sb.save_page_source_to_logs()
sb.save_screenshot_to_logs()
print("Logs have been saved to: ./latest_logs/")
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_indeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
with SB(uc=True, test=True) as sb:
url = "https://www.indeed.com/companies/search"
sb.activate_cdp_mode(url)
sb.sleep(2)
search_box = "input#company-search"
if not sb.is_element_present(search_box):
sb.sleep(2)
sb.solve_captcha()
sb.sleep(1)
company = "NASA Jet Propulsion Laboratory"
Expand Down
13 changes: 7 additions & 6 deletions examples/cdp_mode/raw_indeed_login.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""An example of clicking at custom CAPTCHA coordinates."""
from seleniumbase import SB

with SB(uc=True, test=True, locale="en") as sb:
with SB(uc=True, test=True, incognito=True) as sb:
url = "https://secure.indeed.com/auth"
sb.activate_cdp_mode(url)
sb.sleep(1)
sb.sleep(1.8)
sb.solve_captcha()
sb.sleep(1.8)
sb.type('input[type="email"]', "test@test.com")
sb.sleep(1)
sb.sleep(1.5)
sb.click('button[type="submit"]')
sb.sleep(3.5)
selector = 'div[class*="pass-Captcha"]'
sb.click_with_offset(selector, 32, 42)
sb.sleep(3.2)
sb.solve_captcha()
sb.sleep(4.5)
2 changes: 1 addition & 1 deletion examples/cdp_mode/raw_planetmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
with SB(uc=True, test=True, guest=True) as sb:
url = "www.planetminecraft.com/account/sign_in/"
sb.activate_cdp_mode(url)
sb.sleep(2)
sb.sleep(3)
sb.solve_captcha()
sb.wait_for_element_absent("input[disabled]")
sb.sleep(2)
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.48.3"
__version__ = "4.48.4"
8 changes: 6 additions & 2 deletions seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,9 @@ def __click_captcha(self, use_cdp=False):
selector = "#challenge-form div > div"
elif self.is_element_present('[style="display: grid;"] div div'):
selector = '[style="display: grid;"] div div'
time.sleep(0.025)
self.set_attributes(selector, "style", "text-align: left;")
time.sleep(0.025)
elif self.is_element_present("[class*=spacer] + div div"):
selector = '[class*=spacer] + div div'
elif self.is_element_present(".spacer div:not([class])"):
Expand Down Expand Up @@ -2443,10 +2446,11 @@ def __click_captcha(self, use_cdp=False):
element_rect = self.get_gui_element_rect(selector, timeout=1)
e_x = element_rect["x"]
e_y = element_rect["y"]
x_offset = 28
x_offset = 25
y_offset = 32
if shared_utils.is_windows():
y_offset = 28
x_offset = 27
y_offset = 29
x = e_x + x_offset
y = e_y + y_offset
sb_config._saved_cf_x_y = (x, y)
Expand Down
8 changes: 6 additions & 2 deletions seleniumbase/undetected/cdp_driver/tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,9 @@ async def solve_captcha(self):
selector = "#challenge-form div > div"
elif await self.is_element_present('[style="display: grid;"] div div'):
selector = '[style="display: grid;"] div div'
await self.sleep(0.025)
await self.set_attributes(selector, "style", "text-align: left;")
await self.sleep(0.025)
elif await self.is_element_present("[class*=spacer] + div div"):
selector = '[class*=spacer] + div div'
elif await self.is_element_present(".spacer div:not([class])"):
Expand Down Expand Up @@ -1837,10 +1840,11 @@ async def solve_captcha(self):
element_rect = await self.get_gui_element_rect(selector, timeout=1)
e_x = element_rect["x"]
e_y = element_rect["y"]
x_offset = 28
x_offset = 25
y_offset = 32
if await asyncio.to_thread(shared_utils.is_windows):
y_offset = 28
x_offset = 27
y_offset = 29
x = e_x + x_offset
y = e_y + y_offset
sb_config._saved_cf_x_y = (x, y) # For debugging later
Expand Down