Skip to main content

Undetected Python version of the Playwright testing and automation library.

Project description

🎭 Patchright Python


Patchright Version GitHub Downloads (all assets, all releases)

Patchright is a patched and undetected version of the Playwright Testing and Automation Framework.
It can be used as a drop-in replacement for Playwright.

[!NOTE]
This repository serves the Patchright-Python Package. To use Patchright with NodeJS, check out the NodeJS Package. Also check out the main Patchright Driver Repository


Sponsors

Hyperbrowser Banner Ad
If you’re looking for a high-performance browser automation platform checkout Hyperbrowser. It’s ideal for AI Agents, large-scale web scraping and automated testing.
Hyperbrowser delivers cloud-based browser infrastructure that scales instantly from a few sessions to thousands, with built-in CAPTCHA solving, stealth fingerprinting, and a global proxy network. It integrates seamlessly with Puppeteer, Playwright, and Selenium, so you can be up and running in minutes, no server or proxy management required.

Key Features:

  • Instant scaling: Launch 1,000+ concurrent browsers
  • Captcha Solving: Handles reCAPTCHA, Cloudflare, AWS, and more
  • Stealth mode: Dynamic, human-like fingerprints for undetectable automation
  • Global proxy network: 170+ countries with rotation and geo-targeting
  • Built-in debugging: Live view and session replay for real-time monitoring
  • 1-line integration: Works with Puppeteer, Playwright, Selenium in Node.js or Python

👉 Learn more at hyperbrowser.ai


Install it from PyPI

# Install Patchright with Pip from PyPI
pip install patchright
# Install Chromium-Driver for Patchright
patchright install chromium

Usage

Just change the import and use it like playwright. Patchright is a drop-in-replacement for Playwright!

[!IMPORTANT]
Patchright only patches CHROMIUM based browsers. Firefox and Webkit are not supported.

# patchright here!
from patchright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto('http://playwright.dev')
    page.screenshot(path=f'example-{p.chromium.name}.png')
    browser.close()
import asyncio
# patchright here!
from patchright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page()
        await page.goto('http://playwright.dev')
        await page.screenshot(path=f'example-{p.chromium.name}.png')
        await browser.close()

asyncio.run(main())

Best Practice - use Chrome without Fingerprint Injection

To be completely undetected, use the following configuration:

playwright.chromium.launch_persistent_context(
    user_data_dir="...",
    channel="chrome",
    headless=False,
    no_viewport=True,
    # do NOT add custom browser headers or user_agent
    ...
)

[!NOTE]
We recommend using Google Chrome instead of Chromium. You can install it via patchright install chrome (or via any other installation method) and use it with channel="chrome".


Patches

Runtime.enable Leak

This is the biggest Patch Patchright uses. To avoid detection by this leak, patchright avoids using Runtime.enable by executing Javascript in (isolated) ExecutionContexts.

Console.enable Leak

Patchright patches this leak by disabling the Console API all together. This means, console functionality will not work in Patchright. If you really need the console, you might be better off using Javascript loggers, although they also can be easily detected.

Command Flags Leaks

Patchright tweaks the Playwright Default Args to avoid detection by Command Flag Leaks. This (most importantly) affects:

  • --disable-blink-features=AutomationControlled (added) to avoid navigator.webdriver detection.
  • --enable-automation (removed) to avoid navigator.webdriver detection.
  • --disable-popup-blocking (removed) to avoid popup crashing.
  • --disable-component-update (removed) to avoid detection as a Stealth Driver.
  • --disable-default-apps (removed) to enable default apps.
  • --disable-extensions (removed) to enable extensions

General Leaks

Patchright patches some general leaks in the Playwright codebase. This mainly includes poor setups and obvious detection points.

Closed Shadow Roots

Patchright is able to interact with elements in Closed Shadow Roots. Just use normal locators and Patchright will do the rest.
Patchright is now also able to use XPaths in Closed Shadow Roots.


Stealth

With the right setup, Patchright currently is considered undetectable. Patchright passes:


Documentation and API Reference

See the original Playwright Documentation and API Reference

Extended Patchright API

evaluate Method (Frame.evaluate, Page.evaluate, Locator.evaluate, Worker.evaluate, JSHandle.evaluate)

  • Added isolated_context to choose Execution Context (Main/Isolated). Bool (optional, Defaults to True)
object.evaluate(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)

evaluate_handle Method (Frame.evaluate_handle, Page.evaluate_handle, Locator.evaluate_handle, Worker.evaluate_handle, JSHandle.evaluate)

  • Added isolated_context to choose Execution Context (Main/Isolated). Bool (optional, Defaults to True)
object.evaluate_handle(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)

evaluate_all Method (Locator.evaluate_all)

  • Added isolated_context to choose Execution Context (Main/Isolated). Bool (optional, Defaults to True)
Locator.evaluate_all(
    expression: str,
    arg: typing.Optional[typing.Any] = None,
    ...,
+   isolated_context: typing.Optional[bool] = True
)

Bugs

The bugs are documented in the Patchright Driver Repository.


TODO

The TODO is documented in the Patchright Driver Repository.


Development

Deployment of new Patchright versions are automatic, but bugs due to Playwright codebase changes may occur. Fixes for these bugs might take a few days to be released.


Support our work

If you choose to support our work, please contact @vinyzu or @steve_abcdef on Discord.


Copyright and License

© Vinyzu

Patchright is licensed Apache 2.0


Disclaimer

This repository is provided for educational purposes only.
No warranties are provided regarding accuracy, completeness, or suitability for any purpose. Use at your own risk—the authors and maintainers assume no liability for any damages, legal issues, or warranty breaches resulting from use, modification, or distribution of this code.
Any misuse or legal violations are the sole responsibility of the user.


Authors

Active Maintainer: Vinyzu
Co-Maintainer: Kaliiiiiiiiii

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

phantomwright_driver-1.56.0-py3-none-win_arm64.whl (31.2 MB view details)

Uploaded Python 3Windows ARM64

phantomwright_driver-1.56.0-py3-none-win_amd64.whl (35.6 MB view details)

Uploaded Python 3Windows x86-64

phantomwright_driver-1.56.0-py3-none-win32.whl (35.6 MB view details)

Uploaded Python 3Windows x86

phantomwright_driver-1.56.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (46.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

phantomwright_driver-1.56.0-py3-none-macosx_11_0_universal2.whl (40.6 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

phantomwright_driver-1.56.0-py3-none-macosx_11_0_arm64.whl (39.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

phantomwright_driver-1.56.0-py3-none-macosx_10_13_x86_64.whl (40.6 MB view details)

Uploaded Python 3macOS 10.13+ x86-64

File details

Details for the file phantomwright_driver-1.56.0-py3-none-win_arm64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 db8e243fdf9233664a02ea13263259f0b6753f6157bf519c3238887a5940d7f4
MD5 10cb60d49a3e203683e43f4e4015b533
BLAKE2b-256 383aa33e0270b50fad15d1d2b974fa1987cf80e5baad86d470299bf48d6076ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-win_arm64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 459be792c8cc10c56db7b3d35bf935c2dcddc98278ff205bb9e69fa11420589f
MD5 37323c40ce2030334cbd555e998505b7
BLAKE2b-256 0f14537e16a579c18d5186fed09d6d4975e619a219ecb6508e72e798edf16e46

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-win_amd64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-win32.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 d869a9c76ee1d5367bed0ab6b934cccc9e9da1f9a193ed845697bd284dc6ccd8
MD5 de16bddcc903fe706ecc9e3fd44c8871
BLAKE2b-256 dd18a06ca37766ca578d23daa5dcacd45f259809b19c5aae5f1b347e9cb7ce34

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-win32.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 75fd72383f7b810b253d4879bb289f60aad7fc72e269b431c017afc19bb575ba
MD5 5e180a97cf176b179da396e4d7e95ad4
BLAKE2b-256 4c3d04d14062863657fb9425f1ea4c0874dc85b7681c043c7ad9b97624056718

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f51aa8a1cfbf90915774f789b68c0e0c48c720061b882afc14bda26ce02389b7
MD5 decd118ed957d780c1cb709335cdc7d8
BLAKE2b-256 9238e1b670d76713aa6cd51b786d68de1021d32af6449ed213027fb1d5590ef2

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-manylinux1_x86_64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 ba6f8f2c3911b6426c5d69bad35d51492b56ca92c564c0727bf8b46135696c49
MD5 9f0e575ed4e3d1bcdef0254f8deea714
BLAKE2b-256 9ec8c9c673b14d04bf4fa26739203e9f1c9945a93e366228de866d9a34b1c0d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-macosx_11_0_universal2.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 72a45adaa1d3d674b97c9c5fbfaa38a0e8cfe5e4b1002e3e03724444e8f5d8cd
MD5 844bd33f3d0c84f446ea4ad38bccb4e5
BLAKE2b-256 008e69ff23f6392cfc61181ec3c840e5db40cacd9f64d02aebffefd4fa2bcee2

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-macosx_11_0_arm64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file phantomwright_driver-1.56.0-py3-none-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phantomwright_driver-1.56.0-py3-none-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f5659d2c9b70d386bf769b8fb6a0db92bf499da443e3bb8c5b438cb4d3486839
MD5 5f67937f258c451f522392c4f98085bc
BLAKE2b-256 a4d8b42eb7670f1ecfaf288ac6de5d0d48a1a6a2e556423ed70ac2ff74679f19

See more details on using hashes here.

Provenance

The following attestation bundles were made for phantomwright_driver-1.56.0-py3-none-macosx_10_13_x86_64.whl:

Publisher: patchright_workflow.yml on StudentWan/phantomwright-driver-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page