Skip to content

C_f Challenge Fails in Headless Mode – Works in Headed Mode Only #3820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
softbomber opened this issue Jun 15, 2025 · 1 comment
Closed
Labels
duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@softbomber
Copy link

I tried using the method

sb.activate_cdp_mode("https://..../")
user_agent = sb.execute_script("return navigator.userAgent;")
sb.sleep(15)
sb.uc_gui_click_captcha()

to solve the Cloudflare challenge "Verify you are human by completing...".

I noticed that in headless mode, it doesn't work, but when using headed=True, everything works fine.
It was also observed that if you use a custom user-agent with headed=True, Cloudflare somehow detects that the browser is under automation control.

What should I do to solve this problem?

user_agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
sbase version: latest.

I also tried using the method sb.uc_gui_click_cf() with the same result

@mdmintz mdmintz added duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels Jun 15, 2025
@mdmintz
Copy link
Member

mdmintz commented Jun 15, 2025

Duplicate of #3161 (comment).

UC Mode and CDP Mode don't support headless mode because those use PyAutoGUI for lots of things, and PyAutoGUI doesn't work with a headless browser. (Headless mode isn't needed on Linux because of the special virtual display included.)

To activate the special virtual display, use xvfb=True on Linux to run headed browsers in a GUI-less environment.

If you encounter a CF CAPTCHA that isn't automatically bypassed, use sb.uc_gui_click_captcha() to get through.

Even if not using PyAutoGUI during UC Mode / CDP Mode, a headless browser can still leave a detectable fingerprint.

Note that SeleniumBase already gives you an optimal user agent by default, so unless you know exactly which other agents are valid to use, you'll likely get detected when trying to change it.

@mdmintz mdmintz closed this as completed Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The answer/solution already exists somewhere invalid usage You may need to change what you're doing UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

No branches or pull requests

2 participants