Playwright-Extra reCAPTCHA Plugin: CapSkip as the Provider

For playwright-extra recaptcha support you install one plugin, puppeteer-extra-plugin-recaptcha, which also serves Puppeteer. Register it with chromium.use(), give it a provider function that calls solver.recaptcha() from the capskip package, and page.solveRecaptchas() finds the widget, asks CapSkip for a token and writes it into the page. The built-in provider of the plugin cannot reach a local solver, so that function is the one piece you write. The CapSkip Playwright CAPTCHA solver page shows the other ways to wire CapSkip into Playwright.
What you need
- CapSkip on a Windows PC you own, installed as in the setup guide. I never sent the CapSkip app a task. Every solve below ran against a mock server that I wrote, so each timing and each rule is mine.
- Node.js 20 or later. Playwright 1.65.1 declares 20, the highest of the four packages: capskip 1.8.0 asks for 18, playwright-extra 4.3.6 for 12 and the plugin for 9.11.2. I ran on Node.js 24.22.0, and the finished scripts also on 20.11.1 and 25.2.1.
- The four packages in the table below, and a Chromium build. Playwright 1.65.1 pairs with Chrome for Testing 159.0.8154.6, which was already on my Windows 11 PC.
- A site you are allowed to automate, with a reCAPTCHA v2 checkbox on its form.
- A place for CapSkip to run. Local mode serves the loopback address alone, while Server mode lets other PCs reach it, so your Playwright jobs may run elsewhere. The switch sits under connection settings in the setup guide.
# PowerShell, in a new empty folder npm init -y npm install playwright-extra puppeteer-extra-plugin-recaptcha playwright capskip npx playwright install chromium
| Package | Version I ran | What it does | Published |
|---|---|---|---|
| playwright-extra | 4.3.6 | Adds use() to chromium, firefox and webkit | 2023-03-01 |
| puppeteer-extra-plugin-recaptcha | 3.6.8 | The plugin, shared with Puppeteer | 2023-03-01 |
| playwright | 1.65.1 | The browser driver | 2026-11-13 |
| capskip | 1.8.0 | The client library for CapSkip | 2026-11-16 |
The Playwright adapter is not a separate package. The plugin lists playwright-extra as an optional peer dependency and playwright-extra wraps the browser launcher, so npm installed no Puppeteer. A package named @extra/recaptcha exists as a 2021 pre-release, and I did not use it.
Both packages are old: the versions I ran date from March 2023, and npm lists nothing newer. They still ran on Playwright 1.65.1 and Chrome 159 against the live Google script, but no release has followed. GitHub showed the plugin repository as not archived when I checked.
The test page loads the real Google script with the v2 test sitekey that Google publishes. The mock CapSkip hands out the tokens and the mock site accepts each once. No token went to Google or any other third party, so I can say that the plugin fills the widget, not what Google does with a real token.
Step 1: a provider function that calls CapSkip
The plugin can’t be pointed at CapSkip, because its built-in provider sends https requests to one fixed address. A provider may also be a function, which the plugin source calls with the captchas it found. That route needs no hosts file edit and no certificate.
CapSkip also has a Service Emulator with a hosts file entry that answers for the original address. I did not run it, since it edits the Windows hosts file and the trust store. The built-in provider uses the https module of Node.js, which would also have to trust the certificate CapSkip creates. The Node.js CLI documentation says NODE_EXTRA_CA_CERTS adds a PEM file to the root authorities and is read only at process start. That route is untested.
Save the function as capskip_provider.js, and use your server address as host if CapSkip runs in Server mode.
// capskip_provider.js: a provider function for the reCAPTCHA plugin, backed by CapSkip.
const { CapSkip } = require("capskip");
// Local mode. In Server mode, use your server's address as the host.
const solver = new CapSkip({ host: "127.0.0.1", port: 8080 });
// The plugin calls this with every captcha it found and expects { solutions, error }.
async function capskipProvider(captchas) {
const settled = await Promise.allSettled(
captchas.map(async (captcha) => {
if (captcha._vendor !== "recaptcha") throw new Error(`no solver wired for ${captcha._vendor}`);
// A widget with no challenge (the v3 kind) is not wired here: say so instead of sending a v2 task.
if (captcha._type === "score") throw new Error("score widgets are not wired in this provider");
const options = {};
if (captcha.isEnterprise) options.enterprise = 1;
if (captcha.isInvisible) options.invisible = 1;
if (captcha.s) options["data-s"] = captcha.s;
const requestAt = new Date();
const result = await solver.recaptcha(captcha.sitekey, captcha.url, options);
const responseAt = new Date();
return {
_vendor: captcha._vendor,
id: captcha.id, // the plugin matches a solution to its widget by this id
provider: "capskip",
providerCaptchaId: result.captchaId,
text: result.code, // the token the plugin writes into g-recaptcha-response
requestAt,
responseAt,
duration: (responseAt - requestAt) / 1000,
hasSolution: true,
};
}),
);
// Keep only real tokens: the plugin would write a solution without text into the page.
const solutions = settled.filter((s) => s.status === "fulfilled").map((s) => s.value);
const failed = settled.find((s) => s.status === "rejected");
return { solutions, error: failed ? String(failed.reason) : undefined };
}
module.exports = { capskipProvider };The capskip source accepts enterprise, invisible, data-s, proxy, proxytype and json for a v2 widget, next to the sitekey and the page address, and raises a ValidationException for anything else. The function sends the first three. A hand-made captcha object marked as Enterprise made the mock log enterprise=1 and the data-s value. A real Enterprise widget was out of reach, since Google serves its test sitekey only through the regular script.
By default the plugin skips widgets with no visible challenge, the v3 kind. If you switch them on, it returns them with the type score and with the invisible flag set, and a v2 task for such a widget would be wrong. The function above throws for them instead: a hand-made score widget next to a checkbox widget gave one solution and the error text Error: score widgets are not wired in this provider. I did not wire v3, and nothing was tested against a v3 page.
Step 2: solve the widget from a Playwright script
Save this as signup.js. Set SIGNUP_URL, the two selectors input[name=email] and button[type=submit], and the success text to match your own page.
// signup.js: run it with node signup.js
const { chromium } = require("playwright-extra");
const RecaptchaPlugin = require("puppeteer-extra-plugin-recaptcha");
const { capskipProvider } = require("./capskip_provider");
const SIGNUP_URL = "https://example.com/signup"; // a page with a reCAPTCHA v2 checkbox
const SUCCESS_TEXT = "Verification Success"; // what your site shows after a good form post
// use() registers the plugin before the browser starts.
chromium.use(
RecaptchaPlugin({
provider: { fn: capskipProvider }, // our function, so no id or token is needed
visualFeedback: false, // true tints the widget frame, which shows up in screenshots
}),
);
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto(SIGNUP_URL);
await page.fill("input[name=email]", "[email protected]");
const result = await page.solveRecaptchas();
console.log(`found ${result.captchas.length}, solved ${result.solved.filter((s) => s.isSolved).length}`);
if (result.error || result.solved.length === 0) throw new Error(`no token: ${String(result.error)}`);
await page.click("button[type=submit]");
await page.getByText(SUCCESS_TEXT).waitFor({ timeout: 10_000 });
console.log("form accepted");
} finally {
await browser.close();
}
})();Against the mock on Node.js 24.22.0 it printed one found and one solved, then the success text. The call to solveRecaptchas() returns an object with five parts.
| Key | What it held in my run |
|---|---|
| captchas | One entry for the widget: sitekey, an internal id, the page address, a type of checkbox and an in-viewport flag |
| filtered | Empty. Widgets that your options skip land here, each with a reason |
| solutions | What the provider returned |
| solved | One entry with the response field and isSolved both true. The callback flag was false, since that page has no callback |
| error | Undefined or null when nothing went wrong, a text or an object on failure |
If the widget has a callback, the plugin calls it with the token. A second mock page with a data-callback attribute showed the callback flag true, and the callback received the token.
What changes under Playwright
playwright-extra imitates Puppeteer for a plugin written for it. These five differences came from runs on Playwright 1.65.1 and Node.js 24.22.0 against my mock.
| Situation | What happened | What to do |
|---|---|---|
| A new page, with the method called at once | page.solveRecaptchas was undefined right after browser.newPage() in every run, and a function 3 to 15 ms later in five runs. In one run a page from context.newPage() and a popup opened with window.open were ready after 20 and 15 ms | Call it after goto(), which takes longer |
| The first tab of a persistent context | context.pages()[0] threw a TypeError saying solveRecaptchas is not a function. A tab from context.newPage() worked | Open your own tab, as in the first fragment below |
| The widget sits in an iframe | Calling the page found no captchas and reported no error. Calling the frame solved it. The mock logged the frame address as the page address of the task. My frame was same-origin, and a cross-origin frame is untested | Call the frame, as in the second fragment. Which address a real solve prefers is untested |
| The Google script tag is on the page and no widget ever appears | An empty result after 30041 ms, and after 5022 ms once I called page.setDefaultTimeout(5000). A widget drawn 2.5 seconds after load, with a mock solve delay of 0.5 seconds, was solved in 2999 ms | Lower the default timeout for that page |
| Three contexts with a page each, solving at once | 4.9 and 4.7 seconds in two runs against a mock that took 3 seconds, and the mock saw three open tasks together both times. My mock enforces no limit | Cap the contexts at the Max. Threads value of the reCAPTCHA row, where CapSkip queues the surplus per the setup guide |
Two causes sit in the source. The plugin adds its methods after a CDP call, which explains the few milliseconds, and it hooks the tabs that are open at launch in a step that launchPersistentContext never runs. The 30 second wait comes from the call that waits for the widget. The plugin passes its 10 second limit as the second argument of waitForFunction, and in Playwright that slot is the function argument, so the 30 second default applies. A timeout set with setDefaultTimeout also covers fill, click and goto on that page, so set it on the one page that needs the short wait, not on every page of the run.
The same CDP call is Page.setBypassCSP(true), which the plugin makes on every page it hooks. That call is meant to bypass content security policy in Chromium. I did not measure the effect, so run your own content security policy checks on a hooked page.
Two fragments cover the second and third rows. For a persistent context, replace the launch and page lines of signup.js with the first one, and close the context at the end instead of the browser.
// Persistent profile: replaces chromium.launch() and browser.newPage().
const context = await chromium.launchPersistentContext("./profile", { headless: true });
// context.pages()[0] is the tab Playwright opens itself. It has no solveRecaptchas.
const page = await context.newPage();When the widget lives in a frame, replace the solve line with the second fragment and use the frame for the form actions inside it. Change the part of the address to whatever identifies your own iframe.
// Widget inside an iframe: ask the frame, not the page.
const frame = page.frames().find((f) => f.url().includes("/signup-frame"));
const result = await frame.solveRecaptchas();The packages add one more difference. playwright-extra loads playwright-core before playwright, whichever copy Node.js finds. With another copy of playwright-core (1.57.0) beside Playwright 1.65.1, the plugin ran on the older copy, and the launch failed because the executable of that older browser build did not exist. Naming the launcher yourself avoids the guess. Use this in place of the first require line of signup.js.
const { addExtra } = require("playwright-extra");
const chromium = addExtra(require("playwright").chromium); // pins the Playwright you installedUse it in Playwright Test
The runner owns the browser. If a spec calls chromium.use() and keeps the built-in page fixture, the plugin never sees that page: page.solveRecaptchas was undefined and the call threw a TypeError. Replace the browser fixture with one that playwright-extra launched, and the built-in context and page fixtures build on it. Install the runner with npm install -D @playwright/test.
// fixtures.js: a test object whose browser comes from playwright-extra.
const base = require("@playwright/test");
const { chromium } = require("playwright-extra");
const RecaptchaPlugin = require("puppeteer-extra-plugin-recaptcha");
const { capskipProvider } = require("./capskip_provider");
chromium.use(RecaptchaPlugin({ provider: { fn: capskipProvider }, visualFeedback: false }));
exports.test = base.test.extend({
// Replace the runner's browser with one that playwright-extra launched.
browser: [async ({ launchOptions }, use) => {
const browser = await chromium.launch(launchOptions);
await use(browser);
await browser.close();
}, { scope: "worker" }],
});
exports.expect = base.expect;// signup.spec.js: run it with npx playwright test
const { test, expect } = require("./fixtures");
const SIGNUP_URL = "https://example.com/signup"; // a page with a reCAPTCHA v2 checkbox
test("sign-up form accepts a solved reCAPTCHA", async ({ page }) => {
test.setTimeout(120_000); // the default is 30 seconds, and a real solve takes a while
await page.goto(SIGNUP_URL);
await page.fill("input[name=email]", "[email protected]");
const result = await page.solveRecaptchas();
expect(result.error).toBeFalsy();
expect(result.solved.length).toBeGreaterThan(0);
await page.click("button[type=submit]");
await expect(page.getByText("Verification Success")).toBeVisible();
});The spec passed against the mock in 1.6 to 1.8 seconds on each of the three Node.js versions. The runner hands its launch options to the fixture: the headed option opened a visible window, and the user agent lost its Headless token. Two runner details matter once solves take real time.
- The test timeout is 30 seconds by default. With a mock that needed 45 seconds, the test failed at 30.0 seconds, and with an 8 second limit it failed at 8.0. The mock still showed one task open, because nothing cancels a solve: neither the capskip package nor the plugin has a cancel option.
- Each worker has its own browser and sends its own solve, but only when tests can run on different workers. Tests inside one spec file share a worker. Four copies of the spec in one file, with four workers and a 3 second mock solve, took 19.7 and 19.4 seconds with one task open at a time. Four files with four workers took 6.9 and 6.1 seconds with four tasks open together, and one file with fullyParallel on took 6.0 and 6.0 seconds, also with four. One worker took 19.5 and 19.7 seconds. Set the worker count no higher than that Max. Threads value, or the surplus tasks wait in the CapSkip queue.
When the solve fails, and other common errors
A failed solve comes back in result.error and not as an exception, unless throwOnError is true. The plugin also prints a console line that starts with PuppeteerExtraPluginRecaptcha: An error occured. The mock refused the first task with ERROR_CAPTCHA_UNSOLVABLE, and result.error read ApiException: ERROR_CAPTCHA_UNSOLVABLE while the form post was refused. With throwOnError true the call rejected with the same text behind an extra Error: prefix, which suits a test.
A solution returned without text is the trap. In my run the plugin wrote the string undefined into the response field, called the page callback with an undefined value and reported the widget as solved. That is why the provider above hands back only real tokens and puts the error text in its own field.
A token is good for one form post and for a short time, so call solveRecaptchas() just before the click. The reCAPTCHA token expiration guide explains the lifetime, and the reCAPTCHA v2 in Node.js guide shows the same task without a plugin.
Rows marked seen come from my runs against the mock. The others come from the source of the packages.
| What you see | Cause | Fix |
|---|---|---|
| solveRecaptchas is not a function | A new page not yet hooked, a first persistent tab, or the page fixture of the runner (seen) | Call it after goto, open your own tab, or use the fixture above |
| captchas is empty, no error | The widget sits in an iframe, or an invisible widget has no challenge frame yet and is filtered with the reason solveScoreBased (seen) | Call the frame, or look again after a moment |
| Nothing solved after 30 seconds | The Google script is on the page and no widget ever appears (seen) | Check the page, and lower the wait with setDefaultTimeout |
| error mentions a solution provider | The plugin got no provider (seen) | Pass provider with a fn |
| error holds ApiException | CapSkip refused or failed the task (the code came from my mock) | Read the code in the API docs, then retry once with a new solve |
| Executable doesn’t exist | playwright-extra loaded another copy of playwright-core (seen) | Use addExtra with your playwright |
| Test timeout of 30000ms exceeded | The runner gives up before the solve ends (seen) | Call test.setTimeout |
Server mode: running the jobs on another PC
Server mode lets the Windows machine that runs CapSkip answer jobs from other PCs, so Playwright and its browsers can live elsewhere. Use that machine address as host. Per the setup guide, CapSkip must run as administrator to change modes. I did not try a second PC. When API Key Validation is on, pass your key as apiKey to the constructor.
After the switch, CapSkip answers connections from every address. Add a Windows Firewall block rule for every address outside the PCs that run your tests, because a block rule wins over the allow rule that CapSkip adds, and leave API Key Validation on as a second lock.
FAQ
Does the plugin work in Firefox and WebKit?
I don’t know. The readme of playwright-extra says it does, but the Firefox and WebKit builds that Playwright 1.65.1 needs were not installed here, so every result is Chromium only.
Does it handle hCaptcha too?
The plugin detects hCaptcha widgets too. The function above refuses them, since it wires up reCAPTCHA only, and I ran no hCaptcha page. The capskip package has its own hcaptcha method.
Is the plugin the only route in Playwright?
No. You can read the sitekey yourself, call the SDK and write the token into the page, with no plugin. The plugin adds detection, callback handling and a one-line call, at the price of two packages with no release since 2023.
The reCAPTCHA plugin through playwright-extra comes down to a provider function, a launcher that the plugin can see and a call placed after the page has loaded. A flat-license captcha bypass on your own PC makes a failed solve cost seconds, not a fee. The Node.js CAPTCHA solver page lists the other CAPTCHA types that the same package sends to CapSkip.
