Skip to content

agisota/patchright

 
 

Repository files navigation

🎭 Patchright

Patchright Version
GitHub Downloads (all assets, all releases) 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 Driver. To use Patchright, check out the Python Package or the NodeJS Package.

Important

Patchright only patches CHROMIUM based browsers. Firefox and Webkit are not supported.


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


Scrapeless Banner Ad

If you are looking for a tool focused on browser automation and anti-detection mechanisms, I can recommend Scrapeless Scraping Browser. It is a cloud-based, Chromium-powered headless browser cluster that enables developers to run large-scale concurrent browser instances and handle complex interactions on protected pages. Perfectly suited for AI infrastructure, web automation, data scraping, page rendering, and automated testing.

The Scrapeless Browser provides a secure, isolated browser environment that allows you to interact with web applications while minimizing potential risks to your system.
Key Features

  • Out-of-the-Box Ready: Natively compatible with Puppeteer and Playwright, supporting CDP connections. Migrate your projects with just one line of code.
  • Global IP Resources: Covers residential IPs, static ISP IPs, and unlimited IPs across 195 countries. Transparent costs ($0.6–$1.8/GB) with support for custom browser proxies.
  • Isolated Environment Creation: Each profile uses an exclusive browser environment, enabling persistent login and identity isolation.
  • Unlimited Concurrent Scaling: A single task supports second-level launch of 50 to 1000+ browser instances. Auto-scaling is available with no server resource limits.
  • Edge Node Service (ENS) – Multiple nodes worldwide, offering 2–3× faster launch speed and higher stability than other browsers.
  • Flexible Fingerprint Customization: Generate random fingerprints or customize fingerprint parameters as needed.
  • Visual Debugging: Perform interactive debugging and real-time monitoring of proxy traffic through Live View, and quickly pinpoint issues and optimize actions by replaying sessions page by page with Session Recordings.
  • Enterprise Customization: Undertake customization of enterprise-level automation projects and AI Agent customization.

👉 Learn more: Scrapeless Scraping Browser Playground | Scrapeless Scraping Browser Docs


Patches

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

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:


Bugs

Even though we have spent a lot of time to make Patchright as stable as possible, bugs may still occur. If you encounter any bugs, please report them in the Issues.

Patchright is now tested against the Playwright Tests after every release. See here

Warning

Patchright passes most, but not all the Playwright tests. Some bugs are considered impossible to solve, some are just not relevant. See the list of bugs and their explanation here.

Based on the Playwright Tests, we concluded that its highly unlikely that you will be affected by these bugs in regular usecases.

Init Script Shenanigans

Explanation

To be able to use InitScripts without Runtime.enable, Patchright uses Playwright Routes to inject JavaScript into HTML requests.

Bugs

Playwright Routes may cause some bugs in other parts of your code. Patchright InitScripts won't cause any bugs that wouldn't be caused by normal Playwright Routes.
If you want any of these bugs fixed, you'll have to contact the Playwright team.

Leaks

Patchright InitScripts can be detected by Timing Attacks. However, no antibot currently checks for this kind of Timing Attack and they probably won't for a good amount of time.
We consider them not to be a big risk of detection.


TODO

  • Implement Option to choose Execution Context (Main/Isolated).
  • Fix Fixable Bugs.
  • Implement .patch Updater to easily show Patchright's patches.
  • Setup Automated Testing on new Release.
  • Implement Patchright on .NET and Java.

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

Some Parts of the Codebase are inspired by Driverless. Thanks to Nick Webson for the idea of .patch-File Documentation.


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

About

Undetected version of the Playwright testing and automation library.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 97.3%
  • Shell 2.7%