Skip to content
Guide

Playwright Stealth Not Working in 2026: Cloudflare, Turnstile and the Fixes That Still Work

NSLSolver TeamPublished Updated 9 min read

playwright-stealth does not get you past Cloudflare because it only injects JavaScript overrides into the page, and its own README warns not to expect it "to bypass anything but the simplest of bot detection methods". Cloudflare's documentation says automated testing suites like Playwright are detected as bots by Turnstile, and the signals that give you away (the CDP Runtime.enable call, the headless shell, the IP) sit below anything a stealth script can reach.

What still works in 2026: switch to a patched Playwright build (patchright or rebrowser-playwright) that removes the protocol leaks, run real Chrome headful from a clean IP, and when a Turnstile widget still never resolves, solve the token outside the browser and inject it.

Quick answer: match your error to the fix

The exact errors and symptoms people search for when Playwright with a stealth layer still gets blocked. Find yours:

ImportError: cannot import name 'stealth_sync' from 'playwright_stealth'
playwright-stealth 2.0.0 (June 2025) replaced the stealth_sync / stealth_async functions with a Stealth class. Use Stealth().use_sync(sync_playwright()) or Stealth().apply_stealth_sync(page), or pin playwright-stealth==1.0.6 for old code.
Turnstile stays on "Verifying..." and never returns a token
Turnstile flagged the browser. Cloudflare's testing docs say automated suites such as Playwright are detected as bots. On your own site, use Cloudflare's test sitekeys. On a site you are authorised to automate, fix the leaks below or solve the token server-side.
Turnstile error 600010 / 300030 in the error callback
Cloudflare's table lists 300* and 600* as "Generic challenge failure" with "Bot behavior detected". Retrying the same setup rarely helps. Change the browser build, the headless mode or the IP.
"Just a moment..." loops with headless=True, passes headful
By default Playwright runs headless Chromium on chromium-headless-shell, a separate build from regular Chrome. Run headful, or opt into new headless with channel="chromium" or channel="chrome".
npm install playwright-stealth installs an empty package
On npm, playwright-stealth is a 0.0.1 placeholder from 2021. The JS route is playwright-extra plus puppeteer-extra-plugin-stealth. Install those two (last released 1 March 2023), or skip them and use patchright.
page.on('console') stopped firing after switching to patchright
Expected: patchright disables the Console API to close the Console.enable leak. Log from your Python or Node process instead of the page.
page.pause() does nothing with rebrowser-playwright
A documented limitation of its Runtime.enable fix. Set REBROWSER_PATCHES_RUNTIME_FIX_MODE=0 while debugging.
Works on my laptop, blocked in CI or Docker
Datacenter IPs and GPU-less containers are scored differently from a home connection. Run the same script through a residential IP before changing any code.

Package versions and dates checked on PyPI, npm and GitHub on 2026-12-01. Sources are listed at the end of the article.

Which playwright-stealth are you actually using?

Python: pip install playwright-stealth. Up to 1.0.6 (8 September 2023) the package was AtuboDad's port of the Puppeteer stealth plugin. Since 2.0.0 (18 June 2025) the same PyPI name ships Mattwmaster58's fork, latest 2.0.3 (4 April 2026). Version 2.0.0 was a breaking release: stealth_sync and stealth_async are gone, which is where the ImportError comes from. tf-playwright-stealth (1.2.0, June 2025) is another port of the same evasions.

JavaScript: there is no maintained npm package called playwright-stealth; the name holds a 0.0.1 placeholder from 2021 announcing an "upcoming" plugin. The JS equivalent is playwright-extra with puppeteer-extra-plugin-stealth, both last published on 1 March 2023.

Both are ports of the same evasion set: navigator.webdriver, plugins, languages, WebGL vendor, chrome.runtime and friends. The Python README calls itself "a proof-of-concept starting point". On the issue "Stuck on Cloudflare page open", the maintainer replied that Cloudflare is "too much of a moving target" for this library and recommended tools that patch Playwright's own source instead.

stealth_v2.py
# playwright-stealth 2.x  (pip install -U playwright-stealth)
from playwright.sync_api import sync_playwright
from playwright_stealth import Stealth

# 1.x code was:  from playwright_stealth import stealth_sync; stealth_sync(page)
with Stealth().use_sync(sync_playwright()) as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()  # stealth is applied to every new page
    page.goto("https://example.com")

# Or on one page / context: Stealth().apply_stealth_sync(page)

Why Playwright still gets blocked by Cloudflare

  • Runtime.enable. Playwright sends this CDP command to manage execution contexts, and page JavaScript can detect it. The rebrowser-patches README says all major anti-bot products, Cloudflare and DataDome included, use this technique. An init script cannot hide a protocol call.
  • The UtilityScript helper. Playwright runs page.evaluate through a helper class named UtilityScript, and a page that reads new Error().stack while your code runs can see that name.
  • navigator.webdriver. Chrome launched by Playwright reports navigator.webdriver = true unless --disable-blink-features=AutomationControlled is passed.
  • The headless shell. Headless runs use chromium-headless-shell by default, not the browser real visitors use.
  • Injected overrides. Every stealth evasion is a Proxy or defineProperty over a native API, and that tampering is detectable in itself.
  • IP and behaviour. A datacenter ASN, perfect timing and no mouse movement are scored regardless of fingerprint.

Why Turnstile never resolves under Playwright

Turnstile runs inside an iframe from challenges.cloudflare.com, scores the browser, and only then hands your page a token through its callback. When it decides the browser is automated, it keeps spinning on "Verifying..." or fires the error callback with a 300xxx or 600xxx code, which Cloudflare's error table describes as "Generic challenge failure" and "Bot behavior detected". Cloudflare's testing page is explicit: "Automated testing suites (like Selenium, Cypress, or Playwright) are detected as bots by Turnstile."

If it is your own site, that same page has the answer: use the test sitekeys in CI, for example 1x00000000000000000000AA (always passes) or 2x00000000000000000000AB (always fails). For a third-party site you are authorised to automate, either make the browser look less automated (next sections) or solve the token outside it.

Fix 1: patchright

Patchright is a patched drop-in replacement for Playwright: change the import and keep your code. On 1 December 2026 the current releases are patchright 1.64.4 on PyPI and 1.64.3 on npm (both 2 November 2026), while Playwright itself is at 1.65, so patchright trails upstream by a release. It patches Chromium only; Firefox and WebKit are not supported.

Its main patches: no Runtime.enable (JavaScript runs in isolated execution contexts), no Console.enable (so console events do not work), cleaned launch flags (adds AutomationControlled, removes --enable-automation), and init scripts injected through routes. The README lists Cloudflare among the protections it passes "with the right setup", and that setup is precise:

patchright_setup.py
# pip install patchright && patchright install chrome
from patchright.sync_api import sync_playwright

with sync_playwright() as p:
    context = p.chromium.launch_persistent_context(
        user_data_dir="./profile",
        channel="chrome",   # real Google Chrome, not the bundled Chromium
        headless=False,
        no_viewport=True,
        # no custom user_agent and no extra headers
    )
    page = context.new_page()
    page.goto("https://example.com")

# Node.js: npm i patchright, then chromium.launchPersistentContext(dir,
#   { channel: 'chrome', headless: false, viewport: null })

Fix 2: rebrowser-playwright, the smallest change

If you would rather keep stock Playwright's behaviour (console events included), rebrowser-playwright 1.64.102 (2 November 2026, built from Playwright 1.64.1) applies the rebrowser patches: the Runtime.enable fix (addBinding by default, or alwaysIsolated), a randomly renamed UtilityScript helper, and AutomationControlled added to the launch flags. On Firefox and WebKit the Chromium-specific parts are skipped.

Its README is candid about the limits: the patches do not touch the HeadlessChrome token in the headless user agent, fingerprints (canvas, WebGL, fonts, screen), IP reputation or behaviour, and products such as Cloudflare Turnstile score all of these, "so the patches alone won't get you past them".

install.sh
# Node.js: patched Playwright under the original package names
npm install playwright@npm:rebrowser-playwright playwright-core@npm:rebrowser-playwright-core

# Python: separate package, change the import
pip install rebrowser-playwright
#   from rebrowser_playwright.sync_api import sync_playwright

# Debugging with page.pause()? Turn the Runtime.enable fix off for that run
REBROWSER_PATCHES_RUNTIME_FIX_MODE=0 python debug.py

Fix 3: headless mode, IP and session

  • Headless mode. Playwright's docs say headless runs use the chromium headless shell by default. Run headful (under Xvfb on a server), or opt into the new headless mode with channel="chromium", or use channel="chrome" for Google Chrome.
  • Do not stack layers. Patchright's best practice is Chrome "without fingerprint injection", so adding playwright-stealth on top brings back the injected overrides it avoids.
  • IP first. Test the identical script from a residential IP. If it passes, no code change was needed.
  • Keep a persistent context so a passed challenge and its cookies survive between runs, and replay them from the same IP.
  • Pass action and cdata to the solver only if the widget sets them; most widgets do not.

When to hand Turnstile to a solver

If the patched browser still sits on "Verifying..." for one particular site, the cheapest fix is usually to stop solving Turnstile in the browser. NSLSolver's turnstile type takes the widget's site_key and the page url and returns a token in about 250 ms on average, at $0.80 per 1,000 successful solves. Only successful solves are billed, and sign-ups with Google, Gmail or Proton get free credit with no card.

It covers Cloudflare Turnstile, Cloudflare Challenge, reCAPTCHA v3, Kasada and Akamai (beta), and does not solve reCAPTCHA v2, hCaptcha, image or text CAPTCHAs, FunCaptcha, GeeTest or DataDome. Only automate sites you own or are authorised to access.

Example: solve Turnstile and inject the token into Playwright

Read the sitekey from the rendered page, request a token, write it into the cf-turnstile-response field and fire the widget callback if the site uses one. A token is valid for 300 seconds and can be used once, so solve right before you submit. With patchright, run this evaluate in the main world, because the site's callback lives there.

turnstile_inject.py
import requests
from playwright.sync_api import sync_playwright

def solve_turnstile(site_key: str, url: str) -> str:
    r = requests.post(
        "https://api.nslsolver.com/solve",
        headers={"X-API-Key": "nsl_YOUR_API_KEY"},
        json={"type": "turnstile", "site_key": site_key, "url": url},
        timeout=120,
    )
    data = r.json()
    if not data.get("success"):
        raise RuntimeError(data)
    return data["token"]

INJECT = """(t) => {
  let input = document.querySelector('[name="cf-turnstile-response"]');
  if (!input) {
    input = Object.assign(document.createElement('input'),
      { type: 'hidden', name: 'cf-turnstile-response' });
    document.querySelector('form')?.appendChild(input);
  }
  input.value = t;
  const cb = document.querySelector('[data-callback]')?.getAttribute('data-callback');
  if (cb && "undefined"[cb] === 'function') window[cb](t);
}"""

with sync_playwright() as p:
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    page.goto("https://example.com/login")

    site_key = page.get_attribute("[data-sitekey]", "data-sitekey")
    token = solve_turnstile(site_key, page.url)  # ~250 ms, valid 300 s, single use
    page.evaluate(INJECT, token)
    page.click("button[type=submit]")

Related guides

Frequently asked questions

Why does playwright-stealth not bypass Cloudflare?

It only injects JavaScript that overrides properties such as navigator.webdriver. Cloudflare also detects the CDP Runtime.enable call, the headless shell, the tampering itself, the IP and your behaviour. The maintainer says not to expect it to bypass anything but the simplest bot detection.

How do I fix ImportError: cannot import name 'stealth_sync'?

You have playwright-stealth 2.x, which removed stealth_sync and stealth_async. Use from playwright_stealth import Stealth and then Stealth().use_sync(sync_playwright()) or Stealth().apply_stealth_sync(page). Pinning playwright-stealth==1.0.6 keeps the old API.

Is there a playwright-stealth package for Node.js?

Not a working one: the npm name playwright-stealth is a 0.0.1 placeholder from 2021. Node users combine playwright-extra with puppeteer-extra-plugin-stealth, both last released on 1 March 2023, or move to patchright or rebrowser-playwright.

Patchright or rebrowser-playwright?

Patchright patches more (Runtime.enable, Console.enable, launch flags, closed shadow roots) but disables console events and supports Chromium only. rebrowser-playwright keeps stock behaviour closer and documents its fix modes. Try patchright with its recommended setup first; use rebrowser if you need console events.

Why does Turnstile work headful but not headless in Playwright?

Headless Chromium in Playwright runs on chromium-headless-shell by default, a separate build from regular Chrome. Use headful mode, or opt into the new headless mode with channel="chromium" or channel="chrome".

How do I test Turnstile with Playwright on my own site?

Use Cloudflare's test sitekeys in your test environment, for example 1x00000000000000000000AA (always passes) with the matching test secret 1x0000000000000000000000000000000AA. Cloudflare states that automated suites like Playwright are detected as bots on real sitekeys.

How much does solving Turnstile with NSLSolver cost?

$0.80 per 1,000 successful solves, about 250 ms on average. Failed solves are not billed, and you get free credit when you sign up with Google, Gmail or Proton, with no card required.

Turnstile stuck on "Verifying..."?

Get a valid token in about 250 ms and inject it into your Playwright page. Free credit with Google, Gmail or Proton sign-up, no card, only successful solves billed.