Solve CAPTCHAs in WebdriverIO tests with DeathByCaptcha

Solve CAPTCHAs in WebdriverIO tests with DeathByCaptcha

Posted on 2026-12-02 | 4 min read | Category: captcha-automation | By DeathByCaptcha Engineering Team

CAPTCHA Automation


Solve CAPTCHAs in WebdriverIO tests with DeathByCaptcha

A WebdriverIO suite that stops at a protected form is not a failed test, it is a test that never ran. The fix is a command that asks DeathByCaptcha for the answer and gives it to the page.

Where the solve happens

WebdriverIO runs the specs in a worker process, not in the browser. That is the whole design of this example: the official client is loaded in the worker, so

  • the credentials never reach the page or the session;
  • the token is returned to the spec instead of printed, which keeps it out of the log and out of a CI job's output;
  • one service serves every spec.

Nothing is published as an npm package. The example is a folder you copy.

Files

File What it is
examples/webdriverio/deathbycaptcha.solve.js the solvers: promises over the official client, testable without a browser
examples/webdriverio/deathbycaptcha.service.js the service that turns them into commands
examples/webdriverio/wdio.conf.js a configuration that registers it
examples/webdriverio/specs/recaptcha_v2.spec.js a spec that solves and submits

Setup

npm install deathbycaptcha-lib @wdio/cli @wdio/local-runner @wdio/mocha-framework @wdio/spec-reporter
export DBC_USERNAME=your_username
export DBC_PASSWORD=your_password
# or: export DBC_AUTHTOKEN=your_authtoken

Register the service in wdio.conf.js:

const DeathByCaptchaService = require('./deathbycaptcha.service').default;

exports.config = {
  services: [[DeathByCaptchaService, {}]],
};

Pass the class, not a path: the launcher resolves a string such as './deathbycaptcha.service.js' as an npm package (@wdio/...-service) and fails to start.

The commands

Command Type Returns
browser.dbcSolveRecaptchaV2(sitekey, pageurl) 4 the token
browser.dbcSolveRecaptchaV3(sitekey, pageurl, { action, minScore }) 5 the token
browser.dbcSolveTurnstile(sitekey, pageurl) 12 the token
browser.dbcSolveImage(imagePath) 0 the text to type
browser.dbcBalance() — balance in US cents

sitekey and pageurl have to be the ones of the page under test: the service answers a token for the pair it is given, and the site rejects it for any other. An optional timeout in seconds goes as the third argument; an empty value keeps the client's own default.

What the spec does

  1. Visits Google's reCAPTCHA demo — the vendor's own page, not a third party's production site.
  2. Reads the data-sitekey from the page instead of typing it in.
  3. browser.dbcSolveRecaptchaV2(sitekey, pageurl) asks for a token.
  4. Writes it into #g-recaptcha-response and calls the widget's callback — the same walk as the Playwright, Puppeteer and Cypress samples in the repository, so a team can compare the four.
  5. Submits and waits for .recaptcha-success.
npx wdio run examples/webdriverio/wdio.conf.js      # headless by default
WDIO_HEADED=true npx wdio run examples/webdriverio/wdio.conf.js

The log trap

The configuration runs at logLevel: 'warn' on purpose. At info level the driver prints the RESULT of every command it sends, and the result of the injection is the token — a test log that leaks the very thing it just bought. The integration test asserts that no token-shaped string appears in the output, so a regression here fails the build.

Version

The example runs on WebdriverIO v9. Version 10 needs Node 22 or newer (undici uses zstd), and this repository supports Node 20; v9 runs on both.

The rule that catches people out

A token answer is valid only from the exit IP that solved it. The solve runs on the machine that runs the test, so a solve and the request it is pasted into leave from the same machine — unless your test drives a page through a proxy, in which case pass the same proxy and proxytype in the parameters.

Limits

  • QA on your own pages. These tests are for flows you are allowed to automate — staging, a demo, a page you own. See RESPONSIBLE_USE.md.
  • reCAPTCHA v3 needs the action and the min_score the site expects; a mismatch is a token the site refuses.
  • Images need a file: take the screenshot in the test and pass the path.
  • Never print the token: the commands return it as a value and nothing else should echo it.

Tests

npm run test:unit                                       # solver tests, no network
DBC_USERNAME=... DBC_PASSWORD=... npm run test:integration:webdriverio

The unit tests replace the client with a fake. The integration test runs the real spec in Chrome against the live API, checks that it passed and fails if anything in the output looks like a token. It skips itself when the credentials are not in the environment.

Next steps

  • Service, commands and spec: https://github.com/deathbycaptcha/deathbycaptcha-api-client-nodejs
  • API documentation: https://deathbycaptcha.com/api

Common pitfalls

  • Using a CAPTCHA solving service for illegitimate purposes instead of legitimate automation and testing.
  • Hard-coding credentials or API keys in client-side code that users can inspect.
  • Sending the wrong CAPTCHA type parameter, which returns incorrect or empty responses.
  • Failing to poll for the solution status and not handling timeouts gracefully.
  • Scaling automation without monitoring error rates, response times, and CAPTCHA type coverage.
DBC
Written by DeathByCaptcha Engineering Team
DeathByCaptcha engineers build and operate the CAPTCHA solving technology behind this site. Articles are written by our technical team and checked for accuracy before publishing.
Reviewed by DeathByCaptcha Editorial Team

Get your API key — start solving

Free to try · No credit card · Python, Node.js, Java, C# SDKs

Get your API key


Status: OK

Servers are fully operational with faster than average response time.
  • Average solving time
  • 2 seconds - Normal CAPTCHAs (1 min. ago)
  • 4 seconds - reCAPTCHA V2, V3 (1 min. ago)
  • 12 seconds - others (1 min. ago)
Chrome and Firefox logos
Browser extensions available

Updates

  1. Dec 01: RESOLVED -The temporary technical issue affecting account registration emails and other automated messages has been resolved, and normal email delivery has been restored. We apologize for any inconvenience this may have caused and appreciate your patience and understanding!
  2. Nov 19: RESOLVED - Crypto payments are now fully operational again through the Hekelet payment processor.
  3. May 13: Crypto payments got better! You can now purchase your CAPTCHAs using cryptocurrency through the Hekelet payment processor at https://deathbycaptcha.com/user-pay and receive an extra 20% FREE CAPTCHA credit with every package purchased this way.

  4. Previous updates…

Support

Our system is designed to be completely user-friendly and easy-to-use. Should you have any trouble with it, simply email us at DBC technical support emailcom, and a support agent will get back to you as soon as possible.

Live Support

Available Monday to Friday (10am to 4pm EST) Live support image. Link to live support page