AI Tech NewsYour portal to artificial intelligence
Home / What is Patchright? A Playwright Fork That Looks More Like a Real Browser

What is Patchright? A Playwright Fork That Looks More Like a Real Browser

Patchright is a patched Playwright that removes common automation signals. Learn what it fixes, how to run it, and the limits and rules to respect.

In this article
  1. The Short Version
  2. What Problem Does It Solve?
  3. Key Features
  4. How Is It Different From Similar Tools?
  5. Running It on a Server
  6. What Non-Engineers Should Know
  7. Who Is It For?
  8. Who Might Want to Skip It?
  9. Rules and Risks
  10. How to Get Started
  11. Our Take
  12. Sources

If you've used Playwright to open web pages automatically, you may have hit this wall: a page loads fine in your own browser, but your script gets stuck on a "Just a moment..." screen.

Usually the URL isn't the problem. The site has figured out that it's talking to an automation tool. Patchright was built for exactly this case. It's a patched version of Playwright that you can use with almost no code changes, minus many of the signals that give automation away.

If Playwright is a robot wearing a uniform, Patchright is the same robot in street clothes. It does the same work. It just doesn't stand out at first glance.

The Short Version

Patchright is an open-source drop-in replacement for Playwright that patches the leaks Chromium automation usually exposes. It's useful for reading public information and testing your own sites. It won't get you past a login, and it doesn't make a site's rules optional.

What Problem Does It Solve?

Many websites use bot detection, such as Cloudflare's challenge page, to decide whether a visitor is a person or a program. These systems look for traces of automation in the browser.

Playwright was designed for testing, so it leaves plenty of traces. For example:

  • Chrome launches with flags (startup options) like --enable-automation.
  • Some features enabled through the Chrome DevTools Protocol (CDP, the channel programs use to drive Chrome) can be noticed by the page.
  • Properties like navigator.webdriver announce that the browser is under remote control.

None of that matters when you're testing your own site. It matters a lot when you're trying to read a protected public page.

Key Features

1. Nearly a Drop-In Replacement

The project describes itself as a drop-in replacement for Playwright. In Python, you usually just change the import:

# Before
from playwright.sync_api import sync_playwright
# After
from patchright.sync_api import sync_playwright

Everything else, like page.goto(), locator(), and inner_text(), stays the same.

2. Common Automation Leaks Are Patched

According to the official README, Patchright mainly fixes:

  • The Runtime.enable leak: JavaScript runs in isolated execution contexts to avoid this easily detected call.
  • The Console.enable leak: The Console API is disabled entirely. The trade-off is that your script can't read the page's console messages.
  • Launch flags: It adds --disable-blink-features=AutomationControlled and removes flags such as --enable-automation.
  • Closed shadow roots: You can interact with elements inside closed shadow roots.

3. Use Real Chrome

The recommended setup is the system-installed Google Chrome, headed mode (not headless), and a persistent user data folder:

context = p.chromium.launch_persistent_context(
    user_data_dir="./profile",
    channel="chrome",
    headless=False,
    no_viewport=True,
    # don't set a custom user_agent or extra headers
)

The idea is simple. The closer your setup is to a browser a real person uses, the less likely it is to be flagged.

How Is It Different From Similar Tools?

Tool What it is Browsers Best for
Playwright Official testing and automation framework Chromium, Firefox, WebKit Site testing, general automation
Patchright Patched fork of Playwright Chromium-based only Reading public pages behind bot detection
Selenium Long-running automation framework Most major browsers Existing test suites, multi-language setups
Plain HTTP (curl, requests) Downloads HTML directly No browser needed Static pages, APIs

Rule of thumb: use an API or a plain request when you can. Reach for Playwright when you need a real browser. Try Patchright only when Playwright is being blocked by mistake.

Running It on a Server

We use Patchright on a Linux server to read two kinds of public pages: tourism event pages behind a Cloudflare check, and Facebook page posts that anyone can view without logging in. A few lessons from that work:

  • Servers have no screen, so add a virtual display. Headed mode is recommended, and on a machine without a desktop, xvfb-run provides a virtual screen:

    xvfb-run -a python fetch.py
    
  • Use system Chrome, not the bundled Chromium. Pair it with channel="chrome", and recheck things after Chrome updates.

  • Give each task its own profile folder. Sharing one user_data_dir across jobs causes interference and makes cookies hard to manage.

  • Slow down. Pause a few seconds between pages, fetch only what you need, and cache results so you don't revisit pages you've already read.

  • Plan for failure. Bot detection changes constantly. When a fetch fails, keep the existing data instead of breaking the whole pipeline.

What Non-Engineers Should Know

Patchright makes it more practical for software to look at web pages on your behalf. That's part of what lets AI agents look things up and summarize announcements for you.

It isn't a master key, though. If a page requires a login, Patchright can't see it either. If a site forbids automated collection, using Patchright doesn't change that.

Who Is It For?

  • Editors and site operators who regularly gather public announcements and event details.
  • Developers testing how their own sites behave in a real browser.
  • People who want AI agents to read public web pages.

Who Might Want to Skip It?

  • Anyone hoping to bypass logins, paywalls, or access controls. That's not what it's for, and it may be illegal.
  • Teams testing Firefox or Safari (WebKit). Patchright only supports Chromium-based browsers.
  • Developers who rely on reading console messages while debugging. That feature is turned off.
  • Services that scrape at high volume. It strains websites and is likely to break terms of service.

Rules and Risks

The official README says the project is provided for educational purposes only, that you use it at your own risk, and that users are responsible for any misuse or legal violations. Before you use it, check that:

  • The site's terms of service and robots.txt allow automated access.
  • You only read public information and don't collect personal data.
  • Your request rate doesn't affect the site's normal service.
  • You treat what you collect as source material and verify it against the original announcement before quoting it.

The maintainers also note that Patchright doesn't pass every Playwright test, and some features, such as injected init scripts, can have side effects. Retest after every upgrade.

How to Get Started

Install the Python version:

pip install patchright
patchright install chrome

The Node.js package is also called patchright, and there's a community-maintained .NET version.

Our Take

Patchright's real value isn't "cracking" anything. It's making an automated browser look like an ordinary one again. If you read public information for a living, it can save hours of debugging false blocks.

Still, bot detection keeps evolving, and what works today may not work tomorrow. The sturdier approach is to treat Patchright as a fallback. Use official APIs or open data first, turn to Patchright only when you truly need a browser, and always keep a way to recover when it fails.

Sources