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
4 changes: 2 additions & 2 deletions examples/cdp_mode/raw_cdp_gitlab.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from seleniumbase import sb_cdp

url = "https://gitlab.com/users/sign_in"
sb = sb_cdp.Chrome(url)
sb.sleep(2.5)
sb = sb_cdp.Chrome(url, incognito=True)
sb.sleep(2.2)
sb.gui_click_captcha()
sb.highlight('h1:contains("GitLab.com")')
sb.highlight('button:contains("Sign in")')
Expand Down
24 changes: 14 additions & 10 deletions examples/cdp_mode/raw_cf_clearance.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
from seleniumbase import sb_cdp


def get_cf_clearance_cookie(sb):
all_cookies = sb.get_all_cookies()
for cookie in all_cookies:
if cookie.name == "cf_clearance":
return cookie
return None


url = "https://gitlab.com/users/sign_in"
sb = sb_cdp.Chrome(url)
sb.sleep(2.2)
sb.gui_click_captcha()
sb.sleep(2)
cf_cookie = None
all_cookies = sb.get_all_cookies()
for cookie in all_cookies:
if cookie.name == 'cf_clearance':
cf_cookie = cookie
break
sb = sb_cdp.Chrome(url, incognito=True)
sb.sleep(2.2) # Wait for CAPTCHA to load
sb.gui_click_captcha() # (Only if found)
sb.sleep(2.2) # Wait for CAPTCHA success
cf_cookie = get_cf_clearance_cookie(sb)
if cf_cookie:
print("cf_clearance cookie: %s" % cf_cookie.value)
else:
Expand Down
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.41.7"
__version__ = "4.41.8"
1 change: 1 addition & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,7 @@ def _on_a_cf_turnstile_page(driver):
'data-callback="onCaptchaSuccess"' in source
or "/challenge-platform/scripts/" in source
or 'id="challenge-widget-' in source
or "challenges.cloudf" in source
or "cf-turnstile-" in source
):
return True
Expand Down
7 changes: 7 additions & 0 deletions seleniumbase/core/sb_cdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1661,11 +1661,16 @@ def gui_click_element(self, selector, timeframe=0.25):
self.loop.run_until_complete(self.page.wait())

def _on_a_cf_turnstile_page(self):
time.sleep(0.042)
source = self.get_page_source()
if not source or len(source) < 400:
time.sleep(0.22)
source = self.get_page_source()
if (
'data-callback="onCaptchaSuccess"' in source
or "/challenge-platform/scripts/" in source
or 'id="challenge-widget-' in source
or "challenges.cloudf" in source
or "cf-turnstile-" in source
):
return True
Expand Down Expand Up @@ -1795,6 +1800,7 @@ def gui_click_captcha(self):
self.loop.run_until_complete(self.page.evaluate(script))
self.loop.run_until_complete(self.page.wait())
with suppress(Exception):
time.sleep(0.08)
element_rect = self.get_gui_element_rect(selector, timeout=1)
e_x = element_rect["x"]
e_y = element_rect["y"]
Expand All @@ -1804,6 +1810,7 @@ def gui_click_captcha(self):
else:
y = e_y + 22
sb_config._saved_cf_x_y = (x, y)
time.sleep(0.08)
self.gui_click_x_y(x, y)

def __gui_drag_drop(self, x1, y1, x2, y2, timeframe=0.25, uc_lock=False):
Expand Down