Registry / http-networking / playwright-stealth

playwright-stealth

JSON →
library2.0.3pypypi✓ verified 24d ago

Playwright Stealth is a Python package designed to make Playwright browser automation sessions less detectable by anti-bot systems. It achieves this by patching various browser fingerprints and automation-specific properties. Actively maintained, it currently stands at version 2.0.3 and utilizes a modern context-manager API for integration with Playwright.

pip install playwright-stealth
INSTALL
IMPORT
SIG · PLAYWRIGHT-STEALTH
P
playwright-stealth
http-networkingpythonv2.0.3
Install
3.3s avg
Import
450ms
Disk
86MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.3s · import 0.450s · 157MB
86MB installed
● package 86MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Stealth
from playwright_stealth import Stealth
stealth_async / stealth_sync
from playwright_stealth import stealth_async
These functions were part of the v1.x API and are deprecated. The v2.x API uses a context manager approach.

This quickstart demonstrates the recommended asynchronous usage of `playwright-stealth` with Playwright's context manager. It launches a stealthy Chromium browser, checks the `navigator.webdriver` property (which should be `False` or undefined when stealth is applied), and navigates to a sample page. Remember to install Playwright browser binaries via `playwright install chromium` first.

import asyncio import os from playwright.async_api import async_playwright from playwright_stealth import Stealth async def main(): async with Stealth().use_async(async_playwright()) as p: browser = await p.chromium.launch(headless=True) page = await browser.new_page() # Example: Go to a test page and check navigator.webdriver property # An actual stealth check would involve visiting sannysoft.com or similar await page.goto("https://www.google.com") is_webdriver = await page.evaluate("navigator.webdriver") print(f"Is navigator.webdriver set? {is_webdriver}") # Navigate to another page await page.goto("https://web-scraping.dev/products") title = await page.title() print(f"Page title: {title}") await browser.close() if __name__ == "__main__": asyncio.run(main())
Debug
Known issues
breakingThe API for `playwright-stealth` underwent a breaking change from v1.x to v2.x. Older patterns like `stealth_async(page)` or `stealth_sync(page)` are no longer supported. The current recommended approach uses a `Stealth().use_async(async_playwright())` context manager or `stealth.apply_stealth_async(context)` method for explicit control.
fix
Migrate your code to use the `Stealth` class with its context manager (`async with Stealth().use_async(async_playwright())`) or `apply_stealth_async(context)` method.
affects: >=2.0.0
gotchaWhile `playwright-stealth` helps bypass many common bot detection methods by patching browser fingerprints (e.g., `navigator.webdriver`, User-Agent), it does not provide complete immunity against advanced anti-bot systems. These systems might analyze IP reputation, TLS fingerprints, behavioral patterns, and other infrastructure-level signals, which `playwright-stealth` does not address.
fix
For highly protected websites, consider combining `playwright-stealth` with proxy rotation (especially residential proxies), realistic user behavior simulation (random delays, mouse movements), and session management.
affects: All versions
gotchaThe `playwright` library (on which `playwright-stealth` depends) no longer automatically downloads browser binaries (Chromium, Firefox, WebKit) when installed via `pip` since version 1.38+. If you forget to install the browsers, `playwright-stealth` will fail to launch a browser.
fix
After installing `playwright-stealth`, run `playwright install` (or `playwright install chromium` for a specific browser) in your environment to download the necessary browser binaries.
affects: playwright>=1.38.0
gotchaStealth techniques that work for small-scale testing often fail when scaled up. Consistent browser fingerprints, repeated access patterns from the same IP, and rapid requests can lead to detection and blocking by anti-bot services, even with stealth plugins.
fix
Implement robust infrastructure-level solutions for scaling, such as distributed proxies, diverse user-agent rotation, dynamic header management, and careful pacing of requests to mimic human browsing more closely.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'playwright_stealth'
The 'playwright-stealth' package is not installed or not properly installed.
fix
Install the package using 'pip install playwright-stealth'.
ImportError: cannot import name 'Stealth' from 'playwright_stealth'
The 'playwright_stealth' package does not contain a 'Stealth' class; it provides 'stealth_sync' and 'stealth_async' functions.
fix
Import the correct function: 'from playwright_stealth import stealth_sync' or 'from playwright_stealth import stealth_async'.
AttributeError: module 'playwright' has no attribute 'chromium'
The 'playwright' module is not properly initialized or imported.
fix
Ensure that Playwright is correctly installed and imported: 'from playwright.sync_api import sync_playwright'.
ImportError: cannot import name 'stealth_async' from 'playwright_stealth'
This error arises when attempting to import the `stealth_async` (or `stealth_sync`) function, which was part of the v1.x API, but `playwright-stealth` version 2.x or newer is installed. The v2.x+ API utilizes a `Stealth` class with a context manager.
fix
Update your code to use the modern `Stealth` class and its context manager API. For asynchronous operations, use `from playwright_stealth import Stealth; async with Stealth().use_async(async_playwright()) as p: ...`.
ImportError: cannot import name 'stealth_sync' from 'playwright_stealth'
The direct import of `stealth_sync` was removed in favor of `add_stealth_sync` in recent versions (>=1.0.0) of `playwright-stealth`.
fix
Use `from playwright_stealth import add_stealth_sync` and then call `add_stealth_sync(page)` or `add_stealth_sync(context)`.
Upgrade
Version history
2.0.3latest on PyPI · released Apr 4, 2026
Audit
Dependencies
playwrightrequiredplaywright-stealth patches the underlying Playwright browser instance, thus Playwright is a core dependency.
Agent activity
173 hits · last 30 days
node
159
OpenAI (training)
1
Resources
playwright-stealth — pip install playwright-stealth · libregistry