Skip to content
Programmatic guide

reCAPTCHA v2 solver for Selenium Python

Inject a Sonic-issued reCAPTCHA v2 token into your Selenium Python flow. The driver never sees the widget — the token lands directly in the g-recaptcha-response textarea.

Python · Selenium

Runnable example

from captchasonic import CaptchaSonic
from selenium import webdriver

driver = webdriver.Chrome()
driver.get('https://example.com/login')

sonic = CaptchaSonic('YOUR_API_KEY')
token = sonic.solve(
    type='RecaptchaV2TaskProxyless',
    website_url=driver.current_url,
    website_key='6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-'
).gRecaptchaResponse

driver.execute_script(
    'document.getElementById("g-recaptcha-response").value = arguments[0];', token
)
driver.find_element('css selector', 'form').submit()

Replace YOUR_API_KEY with a real key from your dashboard. The token is good for one form submission.

FAQ

Why does my Selenium reCAPTCHA flow get detected?
Selenium leaks navigator.webdriver=true plus a handful of CDP-specific fingerprint markers that reCAPTCHA Enterprise downscoring picks up. Using a Sonic token instead of clicking the widget sidesteps the fingerprint check entirely.
Do I need undetected-chromedriver?
Not for v2 — the token approach bypasses the widget. For v3 or Enterprise, undetected-chromedriver helps but is not required; the action-bound token we return is independent of the navigating session.
How do I find the websiteKey value?
Inspect the page for a div with class g-recaptcha and read the data-sitekey attribute. For invisibly-embedded v2 widgets, search the HTML for "sitekey" — it's a 40-character string starting with 6L.

How CaptchaSonic compares for this captcha

Feature-by-feature against the four most-mentioned alternatives. Independently benchmarked; numbers refresh quarterly.

FeatureCaptchaSonic2CaptchaCapSolverAnti-CaptchaCapMonster Cloud
AI / ML solver (no human relay)
reCAPTCHA v2 / v3 / Enterprise
Avg. solve time (reCAPTCHA v2)< 3s~12s~8s~10s~7s
Success rate (trailing 30d)99.9%~95%~98%~95%~97%
Price per 1k — reCAPTCHA v2$0.80$2.99$0.90$2.00$1.00
Proxy + proxyless modes
Free trial credits
SDK languages (Py, Node, Go, C#, Java, PHP)66454
Selenium / Puppeteer / Playwright examples
Browser extension
Webhook callbacks
99.9% uptime SLA

Yes / No / Partial reflect publicly documented support. Pricing and solve-time figures snapshot the published rate at the time this page was last updated.

Related guides