Skip to main content

Captcha Solving

TestDriver can automatically solve captchas during your tests using the 2captcha service. This feature works on both Linux and Windows sandboxes.

Quick Start

That’s it! TestDriver will automatically:
  • Detect the captcha type on the page
  • Extract the sitekey
  • Solve the captcha via 2captcha
  • Inject the token into the page
  • Trigger any callbacks

Supported Captcha Types

Getting a 2captcha API Key

  1. Sign up at 2captcha.com
  2. Add funds to your account
  3. Copy your API key from the dashboard

Configuration Options

Full Example

Environment Variables

You can set your API key as an environment variable:
Then use it in your tests:

GitHub Actions

Add the key to your repository secrets and expose it in your workflow:

How It Works

  1. Detection: Scans the page for captcha elements (data-sitekey, script tags, etc.)
  2. Submit: Sends the captcha challenge to 2captcha’s solving service
  3. Poll: Waits for human solvers to complete the captcha
  4. Inject: Injects the solved token into the page’s hidden fields
  5. Callback: Triggers any JavaScript callbacks the page expects

Troubleshooting

”Could not auto-detect captcha”

The captcha element wasn’t found on the page. Try:
  • Waiting for the page to fully load before calling captcha()
  • Providing the sitekey and type manually

Timeout errors

Captcha solving typically takes 10-30 seconds. If you’re getting timeouts:
  • Increase the timeout option
  • Check your 2captcha balance
  • Verify the captcha type is correct

Token not working

Some sites validate tokens immediately. Make sure:
  • The token is injected before form submission
  • The captcha type matches what the site expects
  • For reCAPTCHA v3, the action parameter matches the site’s expected action

Requirements

  • Chrome must be launched with remote debugging enabled (automatic on all sandboxes)
  • A valid 2captcha API key with sufficient balance