CAPTCHAs in Headless Browsers: Chrome, Chromium and Automation

· All articles

Headless Chrome made browser automation cheap to run — no desktop, no display server, a hundred tabs a minute — and it made CAPTCHAs more likely: a browser that launches in milliseconds looks exactly like what the defenses are built to catch. This guide is about running a headless session that gets challenged less, recognising the challenge when it still appears, and solving it with the same token loop the rest of our guides use, with code for Puppeteer and the same route for Playwright and raw CDP.

Why headless trips the defences

A site's anti-bot rules do not inspect your intentions; they inspect the browser. Headless Chrome hands them the evidence:

  • The user agent string. Puppeteer's default headless user agent contains HeadlessChrome; no human browser sends that.
  • navigator.webdriver. Automation layers leave the flag on unless something turns it off.
  • The environment around the page. A machine with no GPU, no plugins, no fonts and no audio devices renders differently, and the checks read exactly those differences.

None of these signals is decisive on its own, and the checks weigh them together. A run that sends a real user agent, renders through the real pipeline and keeps a stable profile can pass where a bare default launch fails — which is why two "headless" runs of the same page can end differently, and why blaming the browser after a single challenge is the wrong reflex.

Modern defence stacks — reCAPTCHA, Cloudflare Turnstile, Amazon WAF — combine those signals with behaviour: how you move, how fast you type, whether the session has history. Headless alone does not guarantee a challenge, and a good headless setup does not prevent one; it changes how often the rules fire.

Run a credible headless session

Chrome's newer headless mode renders through the real browser pipeline, so several of the old tells are gone. Three habits cover most of the rest:

  1. Use the new headless mode. headless: 'new' in Puppeteer (or --headless=new on the command line) instead of the legacy mode.
  2. Send a current user agent. The default one announces automation. Copy the user agent of a recent stable Chrome.
  3. Step aside from the obvious automation flags. Chrome still sets some defaults that a plain browser would not; the common, documented flag --disable-blink-features=AutomationControlled removes the most visible one.
const puppeteer = require('puppeteer');

const browser = await puppeteer.launch({
  headless: 'new',
  args: ['--no-sandbox', '--disable-blink-features=AutomationControlled'],
});

const page = await browser.newPage();
await page.setUserAgent(
  'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 ' +
  '(KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
);
await page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en;q=0.9' });
await page.goto('https://www.example.com/signup');

Playwright does part of this for you: its headless build sends a Chrome-like user agent by default, which is one of the reasons the same page may behave differently under the two tools. Whatever the driver, keep the fingerprint stable between the solve and the submit: a session that changes its user agent halfway through looks worse than either version alone.

When the challenge still appears

Reading the challenge is the first step, and it is the same DOM reading for every driver:

  • reCAPTCHA v2 renders inside iframe[title*="reCAPTCHA"] and stores the answer in g-recaptcha-response;
  • reCAPTCHA v3 runs invisibly — no iframe, a grecaptcha.execute() call and a key in the script URL as ?render=SITEKEY;
  • Cloudflare Turnstile renders its own widget and writes to cf-turnstile-response;
  • Interstitials (Cloudflare, Amazon WAF) replace the page entirely: a page.goto() that arrives at a challenge instead of your form is the headless browser meeting the rules at the door.

The details of each widget, with the field lists the API expects, are on the v2, v3 and Turnstile type pages.

The solving route, briefly

Clicking the widget from inside the headless browser is the fragile path, and stealth plugins that try to hide the automation are an armsrace you do not want to maintain. The route that holds is the same one in every article on this blog: a solving API returns the token, the page receives it.

const HttpClient = require('./lib/endcaptcha.js');

const client = new HttpClient(process.env.EC_USER, process.env.EC_PASS);

const job = await new Promise((resolve) => {
  client.decode({
    type: 4,
    googlekey: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
    pageurl: 'https://www.example.com/signup',
  }).on('response', resolve);
});
if (job.error) throw new Error(job.error);

await page.evaluate((token) => {
  const field = document.querySelector('[name="g-recaptcha-response"]');
  if (field) {
    field.value = token;
    field.dispatchEvent(new Event('input', { bubbles: true }));
    field.dispatchEvent(new Event('change', { bubbles: true }));
  }
}, job.text);

await page.click('button[type="submit"]');

The Node client ships in the downloads of the API documentation page; type=12 with sitekey solves Turnstile through the same object. The Python side and the full field-by-field rules — pageurl, proxies, polling — are in the Selenium integration guide, and the Playwright guide covers the same loop from the other driver.

Puppeteer, Playwright and raw CDP

The three headless stacks share one property: the token is produced outside the browser, so any of them can inject it.

  • Puppeteer gives you page.setUserAgent, page.evaluate and the full CDP under page.target().createCDPSession().
  • Playwright ships browser.newContext() with user agent, locale and timezone in one place — the cleanest way to keep a session consistent.
  • Raw CDP (Puppeteer without the sugar, or the Chrome DevTools endpoint directly) leaves everything manual, including the user agent via Network.setUserAgentOverride.

Whichever stack you use, wrap the launch in one function and reuse it everywhere: the moment two scripts launch the browser with different arguments, the site sees two different visitors from the same address, and the challenges multiply for both.

The difference that matters for CAPTCHAs is not the driver; it is whether the environment stays the same between the solve and the submit. Pick the tool your automation already uses and keep the fingerprint fixed.

Troubleshooting

What you see What it usually means What to do
page.goto() lands on a challenge page The defences fired before your form Read the URL and title first; solve the interstitial, then continue
The widget iframe never appears The provider script is blocked or lazy Wait for the script, check for a CSP that strips it
Works headed, fails headless The fingerprint differs between the two runs Keep the same user agent, locale and flags in both
Token accepted by the API, rejected by the page pageurl differs from the URL the browser is on Read page.url() and solve for exactly that address
The challenge comes back after a few requests Rate or history signals, not headless Slow down, reuse the session cookies, add the proxy to both solve and submit
target closed mid-flow The browser crashed or was closed by the navigation Handle the navigation, re-open the page without recreating the whole browser if possible

Questions developers ask

Is headless still worth it? Yes — for volume, test grids and servers. The trade is that headless needs more care with fingerprints, and the token route removes the CAPTCHA from the equation either way.

Do stealth plugins help? They move the arms race one round; the defences evolve against them. The stable approach is the token: the challenge is answered by a service, not by hiding the browser better.

Does the API care that the browser is headless? No. The solve happens server-side; the browser only injects the answer.

Mobile emulation? Useful for sites that only show mobile forms — keep the emulated user agent and the pageurl consistent, and treat it like any other fingerprint: one session, one identity.

How long does a solve take? The service publishes a seven-second SLA; in practice the poll returns in seconds when the queue is free, and decode() caps the wait for you.

Where do I start? The quick start has the same flow with cURL, and creating an account takes a minute.

Back to all articles

Sign Up

Create Account

Already have an account? please
Login
Terms Of Services

Terms of Services

EndCaptcha Terms of Service:

EndCaptcha is a Data Entry Company that focuses on fast and reliable conversion of Images to Text and general digitization. Any use of the service for activities that are deemed illegal is strictly prohibited.

EndCaptcha is not responsible for the actions of its clients. Any complaint about any particular EndCaptcha client should be reported to [email protected]. EndCaptcha reserves the right to suspend its clients' account if, through an [email protected] report, gets hold of undeniable proof that the client is engaging in illicit activities.

EndCaptcha reserves the right to change at any time its Terms of Service, prices of packages, Service Level Agreement conditions and compensation, and Unsupported Images without prior notice.

Unsupported Activities:

EndCaptcha reserves the right to terminate any client account without notice if, by its sole judgement, EndCaptcha determines that the client is engaged in activities that negatively affect service levels. Examples of these harmful activities are:
- Using EndCaptcha's API in ways that negatively affects the operation of the service
- Constantly submitting images that are unreadable
- Exploiting in any way the Service Level Agreement compensation
- Exploiting the service function used to claim images as incorrectly solved

Ownership of an EndCaptcha account:

All accounts created in EndCaptcha remain as sole property of EndCaptcha, and its parent company. Sharing account details, selling and reselling accounts, and selling awarded coupons is prohibited. Violation of this policy will result in account suspension.

Service Level Agreement:

Even though customers may submit Unsupported Images, and EndCaptcha will do it’s best effort to solve said images in a timely fashion, the Service Level Agreement won't cover any Unsupported Images and won't be available during dates included in the Maintenance and Holidays Calendar. EndCaptcha reserves the right to include Unsupported Images at any time without previous notice.

Additional information about the types of insurances provided in the Service Level Agreement may be found here.

Refunds and Chargebacks:

Any fulfilled claims for chargebacks before consulting our helpdesk will result in an immediate suspension of the clients account and appropriate legal action (fraud).

Refunds are processed in a case-by-case basis. We will not award refunds if:
- The client is unsatisfied with the results obtained when submitting Unsupported Images.
- The client has partially used the service and has no use for remaining balance in the client's account.
- The client was unaware of any explicitly written service constraints before making a purchase.

If a refund is awarded, the client will receive funds equivalent to the remaining credit balance in the client's account.

Maintenance and Holidays Calendar

Maintenance and Holidays Calendar

Although we will try our best to keep maintenance and undercapacity occurrences to a minimum, there will be rare occasions in which these events will be unavoidable, and thus not covered by the Insurances of our Service Level Agreement. The Maintenance and Holidays Calendar will show the foreseeable events of diminished Quality of Service.

Event Description Date Duration
Unsupported Images

Unsupported Images

The following images can be solved by our team of workers, but are not insured by the Slowness Insurance. These images are usually unreadable, math problems, or have a lengthy amount of characters. The same exception applies for the Recaptcha V2 challenges. Due to their complexity, are not eligible for Slowness Insurance


Recaptcha V2 Fast Solving Service Recaptcha Invisible Decoding Solution
Refunds and Chargebacks

Refunds and Chargebacks

Any fulfilled claims for chargebacks before consulting our helpdesk will result in an immediate suspension of the clients account and appropriate legal action (fraud).

Refunds are processed in a case-by-case basis. We will not award refunds if:
- The client is unsatisfied with the results obtained when submitting Unsupported Images.
- The client has partially used the service and has no use for remaining balance in the client's account.
- The client was unaware of any explicitly written service constraints before making a purchase.

If a refund is awarded, the client will receive funds equivalent to the remaining credit balance in the client's account.

Service Level Agreement

Service Level Agreement

EndCaptcha offers a unique Service Level Agreement that compensates its users when there is a drop in Quality Standards.

About Compensation

Users will be compensated with Compensatory Credits, which will be deposited once the currently used Credit Package has been consumed. The amount of Compensatory Credits will be calculated depending on the type of Insurance and the Compensation Coverage Level of the currently used package.

Compensatory Credits, Promotional Credits, and Free Credits won't be subject to the terms of the Service Level Agreement and its insurances.

Compensation Coverage Level

The user will be given a Slowness Insurance and an Outage Insurance. These types of insurances will provide compensation to users whenever certain Quality Standards are not met. There will be different Compensation Coverage Levels depending on what Credit Package was bought. The amount of Compensatory Credits will be the result of multiplying the Compensation Coverage Level percentage with the amount of quantifiable times the Quality Standards are not met.

Slowness Insurance

*Approximately 70% of all images are decoded with-in 7-8 seconds on average. The remainder is also guaranteed to be decoded with-in 11 seconds max. For any images that take longer than 11 seconds to solve, our slowness insurance policies kick in.

The Slowness Insurance will provide compensation to EndCaptcha users for images that are getting typed in more than 11 seconds. The compensation will be calculated on an Image-by-image basis.

Example Case:
Compensation Level: 60% Coverage
Images over 11 seconds: 2,000
Compensation Credits: 1,200

The Slowness Insurance won't cover Unsupported Images, and is not applicable during the time ranges included in the Maintenance and Holidays Calendar.

Outage Insurance

The Outage Insurance will provide compensation to EndCaptcha users when the service suffers from an unexpected outage that renders the service partially or completely unresponsive. The Outage Insurance will only cover cases of registered server problems on EndCaptcha's side, it will not cover issues in the user's side or connectivity problems between the user and EndCaptcha.

The Outage Insurance will only compensate credits in accordance with the usual activity of the users during the event. The usual activity of the user will be determined by the average past submissions made by the user during the weekday and time of the outage event.

Example Case:
Compensation Level: 100% Coverage
Usual Activity During Event: 2,000 Images
Compensation Credits: 2,000 Images

The Outage Insurance will be evaluated on a case by case basis whenever the user opens an outage claim at [email protected]. For outage claims to be valid, they have to be opened with-in 72 hours of the outage occurring.

The Outage Insurance is not applicable during the Maintenance time ranges included in the Maintenance and Holidays Calendar, which have been announced a minimum of 12 hours in advance. The Outage Insurance is not applicable when deliberate attacks to our service are made.

EndCaptcha reserves the right to change its Service Level Agreement without prior notice.