Skip to content
Programmatic guide

reCAPTCHA v2 solver for Playwright Node.js

Inject a Sonic-issued reCAPTCHA v2 token from Playwright Node.js. Faster and more reliable than driving the widget — the page never sees mouse motion at all.

Node.js · Playwright

Runnable example

import { chromium } from 'playwright'
import { CaptchaSonic } from 'captchasonic'

const browser = await chromium.launch()
const page = await browser.newPage()
await page.goto('https://example.com/login')

const sonic = new CaptchaSonic('YOUR_API_KEY')
const { gRecaptchaResponse } = await sonic.solve({
  type: 'RecaptchaV2TaskProxyless',
  websiteURL: page.url(),
  websiteKey: '6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-',
})

await page.evaluate(
  (token) => { document.getElementById('g-recaptcha-response').value = token },
  gRecaptchaResponse
)
await page.click('form button[type="submit"]')

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

FAQ

Does Playwright trigger reCAPTCHA detection?
Playwright is harder to fingerprint than Selenium by default — no navigator.webdriver, no automatic CDP markers. But Enterprise reCAPTCHA still scores the session; using a Sonic token avoids the scoring step entirely.
Can I run this in headless mode?
Yes. Token injection works the same in headless and headed Playwright sessions — the token lives in a DOM element, not in browser interaction history.
How long is the token valid?
reCAPTCHA v2 tokens are valid for around 120 seconds. Submit the form immediately after writing the token to maximize acceptance.

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