ProductsIntegrationsResourcesDocumentationPricing
Start Now

© 2026 CapSolver. All rights reserved.

CONTACT US

Slack: lola@capsolver.com

Products

  • reCAPTCHA v2
  • reCAPTCHA v3
  • Cloudflare Turnstile
  • Cloudflare Challenge
  • AWS WAF
  • Browser Extension
  • Many more CAPTCHA types

Integrations

  • Selenium
  • Playwright
  • Puppeteer
  • n8n
  • Partners
  • View All Integrations

Resources

  • Referral System
  • Documentation
  • API Reference
  • Blog
  • FAQs
  • Glossary
  • Status

Legal

  • Terms & Conditions
  • Privacy Policy
  • Refund Policy
  • Don't Sell My Info
Blog/Cloudflare/How to Solve Cloudflare Turnstile Captchas With Selenium
Oct11, 2024

How to Solve Cloudflare Turnstile Captchas With Selenium

Ethan Collins

Ethan Collins

Pattern Recognition Specialist


Cloudflare's Turnstile Captchas are designed to identify and impede automated traffic, creating significant hurdles for web scraping and automation. However, by leveraging a headless browser like Selenium, you can effectively navigate these obstacles. That said, standard Selenium setups may still trigger Cloudflare’s sophisticated defenses.

In this blog, we’ll discuss several effective techniques for overcoming Cloudflare Turnstile Captchas using Selenium

Understanding Cloudflare Turnstile Captchas

Cloudflare Turnstile Captchas are advanced challenges intended to distinguish between human users and automated bots. Unlike traditional CAPTCHAs, Turnstile utilizes various behavioral and interaction-based assessments, such as analyzing mouse movements, click patterns, and other interaction metrics, to determine user legitimacy.

Why Choose Selenium?

Selenium is a robust tool for automating web browsers, allowing you to simulate user actions like clicks, form submissions, and navigation. However, due to its automated nature, conventional Selenium setups can still be flagged by Cloudflare’s security systems. To effectively manage Turnstile Captchas, integrating Selenium with additional tools and techniques can significantly enhance your web scraping success.

Effective Techniques for Solving Cloudflare Turnstile Captchas with Selenium

1. Implementing CapSolver

One of the most efficient methods for solving CAPTCHAs is to utilize a CAPTCHA solving service like CapSolver. This service leverages advanced algorithms and human solvers to quickly and accurately solve various CAPTCHA types, including Cloudflare Turnstile.

Bonus Code

Struggling with the repeated failure to completely solve the irritating captcha?

Discover seamless automatic captcha solving with Capsolver AI-powered Auto Web Unblock technology!

Claim Your Bonus Code for top captcha solutions; CapSolver: WEBS. After redeeming it, you will get an extra 5% bonus after each recharge, Unlimited

Steps to Implement:

  1. Sign up for a CapSolver account.
  2. Integrate CapSolver’s API into your Selenium script.

Example Code:

python Copy
# pip install requests
import requests
import time
 
api_key = "YOUR_API_KEY"  # your api key of capsolver
site_key = "0x4XXXXXXXXXXXXXXXXX"  # site key of your target site
site_url = "https://www.yourwebsite.com"  # page url of your target site
 
def capsolver():
    payload = {
        "clientKey": api_key,
        "task": {
            "type": 'AntiTurnstileTaskProxyLess',
            "websiteKey": site_key,
            "websiteURL": site_url,
            "metadata": {
                "action": ""  # optional
            }
        }
    }
    res = requests.post("https://api.capsolver.com/createTask", json=payload)
    resp = res.json()
    task_id = resp.get("taskId")
    if not task_id:
        print("Failed to create task:", res.text)
        return
    print(f"Got taskId: {task_id} / Getting result...")
 
    while True:
        time.sleep(1)  # delay
        payload = {"clientKey": api_key, "taskId": task_id}
        res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
        resp = res.json()
        status = resp.get("status")
        if status == "ready":
            return resp.get("solution", {}).get('token')
        if status == "failed" or resp.get("errorId"):
            print("Solve failed! response:", res.text)
            return
 
token = capsolver()
print(token)

In this code, replace YOUR_API_KEY, 0x4XXXXXXXXXXXXXXXXX, and https://www.yourwebsite.com with your actual CapSolver API key, the site key from the target site, and the URL of the page you are targeting, respectively. This script will create a task for solving the Turnstile Captcha and return the solution token.

2. Using an Undetected ChromeDriver

To avoid detection by Cloudflare, employing an undetected version of ChromeDriver is crucial. Cloudflare's anti-bot systems can easily recognize standard ChromeDriver instances, leading to CAPTCHA challenges. An undetected ChromeDriver modifies the browser's fingerprint and behavior to minimize detection chances.

Steps to Implement:

  1. Download an undetected ChromeDriver package, such as undetected-chromedriver.
  2. Configure Selenium to use this modified version.

Example Code:

python Copy
from undetected_chromedriver.v2 import Chrome, ChromeOptions

options = ChromeOptions()
options.add_argument('--headless')  # Use headless mode if needed
driver = Chrome(options=options)

driver.get('https://example.com')
# Perform necessary actions and handle CAPTCHA

3. Utilizing SeleniumBase

SeleniumBase is an extension for Selenium that enhances functionality and ease of use for web scraping. It simplifies the management of web interactions and automates complex tasks more effectively.

Steps to Implement:

  1. Install SeleniumBase via pip:

    bash Copy
    pip install seleniumbase
  2. Use SeleniumBase’s features to manage web interactions and handle CAPTCHAs.

Example Code:

python Copy
from seleniumbase import BaseCase

class MyTestClass(BaseCase):
    def test_example(self):
        self.open('https://example.com')
        # Perform necessary actions and handle CAPTCHA

4. Employing the Selenium Stealth Plugin

The Selenium Stealth plugin helps mask your automation efforts, making it more difficult for Cloudflare to detect bot usage. This plugin modifies browser behavior to simulate realistic user interactions.

Steps to Implement:

  1. Install the Selenium Stealth plugin:

    bash Copy
    pip install selenium-stealth
  2. Integrate the plugin with your Selenium setup.

Example Code:

python Copy
from selenium import webdriver
from selenium_stealth import stealth

driver = webdriver.Chrome()

stealth(driver,
        languages=["en-US", "en"],
        vendor="Google Inc.",
        platform="Windows",
        webgl_vendor="Google Inc.",
        render="WebKit",
        fix_hairline=True
       )

driver.get('https://example.com')
# Perform necessary actions and handle CAPTCHA

5. Utilizing Premium Proxies

Using premium proxies can help you avoid IP bans by distributing your traffic across multiple addresses. High-quality proxies significantly reduce the risk of detection and blocking by Cloudflare.

Steps to Implement:

  1. Acquire a list of premium proxies from a trusted provider.
  2. Configure Selenium to use these proxies for web requests.

Conclusion

Successfully navigating Cloudflare Turnstile Captchas requires a combination of advanced techniques and tools. By integrating CapSolver with Selenium, utilizing undetected ChromeDriver versions, leveraging SeleniumBase, employing stealth plugins, and using premium proxies, you can enhance your web scraping capabilities while ensuring compliance with web security protocols. Always remember to adhere to ethical standards and use these tools responsibly in your web scraping endeavors.

More

CloudflareApr 21, 2026

Cloudflare Turnstile Verification Failed? Causes, Fixes & Troubleshooting Guide

Learn how to fix the "failed to verify cloudflare turnstile token" error. This guide covers causes, troubleshooting steps, and how to defeat cloudflare turnstile with CapSolver.

Emma Foster
Emma Foster
CloudflareApr 20, 2026

Best Cloudflare Challenge Solver Tools: Comparison & Use Cases

Discover the best cloudflare challenge solver tools, compare API vs. manual automation, and find optimal solutions for your web scraping and automation needs. Learn why CapSolver is a top choice.

Contents

Ethan Collins
Ethan Collins
CloudflareApr 16, 2026

How to Solve Cloudflare Turnstile in Vehicle Data Automation

Learn how to handle Cloudflare Turnstile in vehicle data and public records automation. Use CapSolver and n8n to automate record scraping efficiently.

Lucas Mitchell
Lucas Mitchell
CloudflareApr 14, 2026

CAPTCHA Error 600010: What It Means and How to Fix It Fast

Facing CAPTCHA Error 600010? Learn what this Cloudflare Turnstile error means and get step-by-step solutions for users and developers, including CapSolver integration for automation.

Anh Tuan
Anh Tuan