This page helps Selenium teams integrate captcha solving with stable, repeatable workflows for test and automation pipelines.
Death By Captcha (DBC) lets Selenium scripts resolve captcha challenges through the API instead of manual interaction: your script extracts the challenge parameters from the page, requests a solution from DBC, injects the result back into the page, and continues the flow. This page is the quickstart: installation, a runnable code sample, and supported task notes.
Python:
pip install selenium deathbycaptcha-official
Use your DBC account credentials in the client. Create an account and check pricing and balance before running the flow.
import json
import os
import time
import deathbycaptcha
from selenium import webdriver
from selenium.webdriver.common.by import By
USERNAME = os.getenv('DBC_USERNAME')
PASSWORD = os.getenv('DBC_PASSWORD')
DEMO_URL = 'https://www.google.com/recaptcha/api2/demo'
def solve_recaptcha_v2(driver):
# 1. extract the challenge parameters from the page
sitekey = driver.find_element(By.ID, 'recaptcha-demo').get_attribute('data-sitekey')
token_params = json.dumps({'googlekey': sitekey, 'pageurl': DEMO_URL})
client = deathbycaptcha.SocketClient(USERNAME, PASSWORD)
if client.get_balance() <= 0:
raise SystemExit('No balance - top up before solving.')
# 2. request the solution token from DBC (type 4 = reCAPTCHA v2 token)
result = client.decode(type=4, token_params=token_params)
return result['text'] if result else None
driver = webdriver.Firefox()
driver.get(DEMO_URL)
token = solve_recaptcha_v2(driver)
if not token:
print('No solution yet - retry with backoff')
raise SystemExit(1)
# 3. inject the token back into the page
driver.execute_script("document.getElementById('g-recaptcha-response').value = arguments[0]", token)
# 4. submit and wait for the success element
driver.find_element(By.ID, 'recaptcha-demo-submit').click()
time.sleep(2)
print(driver.find_element(By.CLASS_NAME, 'recaptcha-success').text)
driver.quit()
Full runnable version: examples/deathbycaptcha-python-selenium in the official Python client repository
| Need | Selenium context | DBC path |
|---|---|---|
| Stable token workflow | Deterministic handling in repeated automation runs. | API-driven token flow with explicit retry/time bounds. |
| Type coverage | Different projects hit different challenge classes. | Use type-specific endpoints and validate each scenario separately. |
| Operational support | Production issues need quick diagnosis. | Support and reliability surfaces for escalation and planning. |
| Topic | Note |
|---|---|
| Captcha types (API) | reCAPTCHA v2 and v3, Cloudflare Turnstile, GeeTest, DataDome, and image/text captchas. |
| Flow | Extract the sitekey from the page, request the token from the DBC API (type 4), inject it back and submit the form. |
| Balance | Solutions are paid from the account balance; check it before decoding. |
| Retries | No solution returned means transient: retry with backoff, as the official example does. |
| API vs extension | This flow uses the API inside your script; the browser extension is the no-code path for manual browsing. |
| Supported browsers | Any WebDriver-supported browser; the official sample runs on Firefox and Chrome. |
For Selenium captcha solver deployment, confirm stable token flow first, then connect reliability and pricing pages to finalize production planning.