👑 CaptchaKings
  • Home
  • Features
  • Pricing
  • Documentation
Login Sign Up

Selenium Captcha Solver

Bypass reCAPTCHA, hCaptcha & image captchas inside Selenium WebDriver — Last Updated: August 29, 2026

⚡ TL;DR: Selenium can't solve CAPTCHAs alone. The working recipe is: grab the sitekey from the page → send it to the CaptchaKings API → receive a valid token in ~3 seconds → inject it with driver.execute_script() → submit. Full working code below. Free $0.50 credit on signup — no card required.

Why Selenium Gets Blocked by CAPTCHAs

reCAPTCHA, hCaptcha, and Cloudflare Turnstile are specifically designed to detect browser automation. Even with undetected-chromedriver or selenium-stealth, high-traffic sites will eventually challenge your bot. Fighting the detection is an arms race you will lose — the professional approach is to solve the challenge programmatically and continue your automation flow.

Step 1 — Install the Dependencies

bash
pip install selenium captchakings
# Optional but recommended for fewer detections:
pip install undetected-chromedriver

Step 2 — Solve reCAPTCHA v2 Inside Selenium

This complete, runnable example opens a page, extracts the sitekey, solves it with CaptchaKings, and injects the token:

python
import time
from selenium import webdriver
from captchakings import CaptchaKings

API_KEY  = "ck_your_api_key_here"          # from captchakings.com/dashboard
PAGE_URL = "https://example.com/signup"     # page with the reCAPTCHA

client = CaptchaKings(API_KEY)
driver = webdriver.Chrome()
driver.get(PAGE_URL)

# 1. Extract the sitekey rendered on the page
sitekey = driver.execute_script("""
    const el = document.querySelector('[data-sitekey]');
    return el ? el.getAttribute('data-sitekey') : null;
""")
print("sitekey:", sitekey)

# 2. Ask CaptchaKings to solve it (returns a valid g-recaptcha-response token)
token = client.solve_recaptcha_v2(sitekey=sitekey, page_url=PAGE_URL)
print("token received in <3s")

# 3. Inject the token and submit
driver.execute_script("""
    document.getElementById('g-recaptcha-response').innerHTML = arguments[0];
    document.getElementById('g-recaptcha-response').style.display = 'block';
""", token)
driver.execute_script("document.querySelector('form').submit()")

time.sleep(3)
print("Done:", driver.current_url)
driver.quit()

Step 3 — Solve Image / Text CAPTCHAs (3 Lines)

For classic image captchas, screenshot the element and send it straight to the API:

python
img = driver.find_element("css selector", "#captcha-image")
img.screenshot("captcha.png")

result = client.solve("captcha.png")
print(result["prediction"], "| confidence:", result["confidence"])

Supported CAPTCHA Types in Selenium Flows

CAPTCHA TypeAvg. Solve TimePrice / 1,000
reCAPTCHA v2 / v3 / Enterprise< 3 s$0.60 – $2.00
hCaptcha / hCaptcha Enterprise< 3 s$0.60 – $2.00
Cloudflare Turnstile< 3 s$0.60 – $2.00
AWS WAF (Amazon)< 4 s$1.00 – $2.00
Image / Text / Math / Number< 2 s$0.30 – $0.80
GeeTest, FunCaptcha, DataDome + 50 more< 4 ssee pricing

Pro Tips for Production Selenium Bots

  1. Reuse sessions. Solve the captcha once, then persist cookies (driver.get_cookies()) instead of re-solving on every run.
  2. Rotate residential proxies. Pair your solver with the CaptchaKings IP Rotator so the IP that solves the captcha matches the IP that submits the form.
  3. Handle failures idempotently. Failed solves are not billed — wrap the call in a retry with exponential backoff and you only pay for successes.
  4. Inject, don't click. Token injection via execute_script is far more reliable than simulating clicks on the reCAPTCHA iframe.

Frequently Asked Questions

How do I bypass reCAPTCHA in Selenium Python?

Extract the sitekey, send it to CaptchaKings, inject the returned token into #g-recaptcha-response, then submit the form — exactly as shown in Step 2 above.

Does this work with undetected-chromedriver and headless mode?

Yes. The solver runs server-side, so it works with any WebDriver flavor: headless Chrome, Firefox, undetected-chromedriver, and remote Selenium Grid / BrowserStack sessions.

What happens if the token is rejected?

Call client.report_bad(task_id) for an automatic refund of that solve, then request a fresh token. Rejected solves are rare (success rate is above 99% for reCAPTCHA v2) and always refunded.

🎁 Free $0.50 credit — enough for 600+ image captchas or ~250 reCAPTCHA solves. Create your API key →

Related Integration Guides

Playwright Captcha Solver Puppeteer Captcha Solver reCAPTCHA Solver API API Documentation Python Automation Tutorial
Get Your Free API Key
Back to Home
👑 CaptchaKings

Fastest and Cheapest AI CAPTCHA Solver Service

Integrations

  • Selenium
  • Playwright
  • Puppeteer
  • API Docs

Legal

  • Privacy Policy
  • Refund Policy
  • Terms of Service
  • SLA 99.9%

© 2026 CaptchaKings.com. All rights reserved.