Skip to content

Add gui_click_captcha() to the pure CDP formats #3945

@mdmintz

Description

@mdmintz

Add gui_click_captcha() to the pure CDP formats

Eg, when complete, a script that uses that may look something like this:

from seleniumbase import sb_cdp

url = "https://seleniumbase.io/apps/turnstile"
sb = sb_cdp.Chrome(url)
sb.gui_click_captcha()
sb.assert_element("img#captcha-success")
sb.sleep(2)
sb.driver.stop()

Or maybe something more advanced like this:

from seleniumbase import sb_cdp

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
if cf_cookie:
    print("cf_clearance cookie: %s" % cf_cookie.value)
else:
    print("Didn't find the cf_clearance cookie!")
sb.driver.stop()

You may need to add sleep time for the page to fully load before calling gui_click_captcha().
(Since the CAPTCHA is hidden behind Shadow-DOM, we can't see when the Turnstile is ready to be clicked, but we can still click it.)

Metadata

Metadata

Assignees

Labels

UC Mode / CDP ModeUndetected Chromedriver Mode / CDP ModeenhancementMaking things better

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions