Overview
Cloudflare Turnstile and other challenges can block automated browsers. Zendriver includes built-in functions to detect and solve these challenges automatically, allowing your scripts to continue without manual intervention.Quick start
The simplest way to handle Cloudflare challenges is using theverify_cf() function:
How it works
Zendriver’s Cloudflare bypass works by:- Detecting the challenge: Scanning the DOM for shadow roots containing Cloudflare iframe elements
- Locating the checkbox: Finding the interactive challenge element (usually a checkbox)
- Simulating clicks: Using mouse coordinates to click the challenge authentically
- Verifying completion: Monitoring the challenge input element to confirm it’s been solved
Zendriver uses real browser automation, not headless mode, which helps avoid detection. The challenge solving is done through authentic mouse events.
Configuration options
Theverify_cf() function accepts several parameters to customize behavior:
Parameters
The tab/page object where the challenge appears
Delay in seconds between click attempts. Increase this if challenges are failing.
Maximum time in seconds to wait for the challenge to appear and be solved.
Optional CSS selector for the challenge input element. Use if the default detection fails.
When
True, visually highlights the corners of the challenge element. Useful for debugging.Checking for challenges
You can check if a Cloudflare challenge is present without solving it:Advanced: Finding challenge elements
For custom handling, you can manually locate Cloudflare challenge elements:(host_element, shadow_root_element, challenge_iframe)
- host_element: The DOM element containing the shadow root
- shadow_root_element: The shadow root element itself
- challenge_iframe: The iframe containing the Cloudflare challenge
Waiting for challenges
Usecf_wait_for_interactive_challenge() to wait for a challenge to appear and become visible:
Best practices
Use reasonable timeouts
Set
timeout to at least 15-30 seconds. Challenges can take time to load and solve.Increase click_delay for difficult challenges
Some challenges are more sensitive to timing. Try
click_delay=7 or higher if you’re getting failures.Handle failures gracefully
Wrap
verify_cf() in a try-except block and implement retry logic or fallback behavior.Don't solve challenges too quickly
Solving challenges instantly can trigger detection. The default delays are tuned for natural behavior.
Debugging challenges
If challenges aren’t being solved, use these debugging techniques:Visual debugging
Check challenge detection
Take screenshots
Limitations
Combining with anti-detection
For best results, combine Cloudflare bypass with anti-detection features:Troubleshooting
TimeoutError: Challenge not found
TimeoutError: Challenge not found
The challenge iframe couldn’t be located within the timeout period. This could mean:
- The site doesn’t use Cloudflare
- The challenge hasn’t loaded yet (increase timeout)
- The page structure is different (check with
cf_find_interactive_challenge)
Challenge appears but isn't solved
Challenge appears but isn't solved
Try these solutions:
- Increase
click_delayto 7-10 seconds - Increase
timeoutto 30-60 seconds - Use
flash_corners=Trueto debug click locations - Check if the challenge requires manual solving (CAPTCHA)
Browser is detected even without challenges
Browser is detected even without challenges
Cloudflare detection goes beyond challenges. See the Anti-detection guide for additional configuration options.
Challenge selector not found
Challenge selector not found
The default selectors are
input[name=cf-turnstile-response] and input[name=cf_challenge_response]. If these don’t work, inspect the page and provide a custom selector:Next steps
Anti-detection
Configure Zendriver to avoid detection
Docker deployment
Run Zendriver in production with Docker