Skip to content
Agents tracked: 506 Releases (7d): 634 Agent status: 4 with issuesSince last limit reset: Claude 15d · Codex 0d For AI agents: Markdown Updated Nov 26, 2026

Playwright (Python)

High-level Python API for automating browser testing and web scraping.

Scraping, browsers and parsingPYPI

GitHubWebsite

1. License

License from PyPI license expression.

github.com/microsoft/playwright-python

From the package registry and GitHub, checked daily. Tap a verdict to see its source.How we checkedReport an error

What Playwright (Python) does

One Python library drives Chromium, Firefox and WebKit through matching sync and async APIs, and the wider Playwright project now also offers an MCP server and a CLI that give AI agents accessibility snapshots instead of screenshots.

Playwright (Python) popularity

77 / 100
Gid Score, #153 overall
34.7M
downloads a week, pypi
15.1K
GitHub stars
76
agent projects use it
Playwright (Python): downloads per weekPyPI, playwright 34,398,826
Playwright (Python): GitHub starsmicrosoft/playwright-python 15,125

Gid Score measures public popularity and activity, not quality. How the Gid Score is calculated

How Playwright (Python) is used

  • Playwright (Python) is a dependency in 76 of the 6,258 public GitHub projects set up for AI coding agents that we scanned (4.7% of the 1,623 Python ones), #5 of 141 in scraping, browsers and parsing.
  • Counting the projects our scan samples by dependency (Solana 3,067, Ethereum and EVM 1,774, 3D and games 3,130, agent frameworks and SDKs 13,750), it appears in 814; those are left out of every share on this page.
  • The most used alternative in our scan is Selenium (27 projects).
  • Projects that use it most often also use python-dotenv (64.5%), Uvicorn (52.6%), Pillow (44.7%).
  • It is more common in projects set up for OpenClaw (4.8%) than for GitHub Copilot (0.8%).

By coding agent

42 projects, 1.3%
26 projects, 1.1%
24 projects, 0.8%
16 projects, 4.8%
7 projects, 1.5%
5 projects, 1.5%
5 projects, 1.8%

Often used with

In 64.5% of its projects
In 52.6% of its projects
In 44.7% of its projects
In 43.4% of its projects
In 40.8% of its projects
In 39.5% of its projects
In 38.2% of its projects
In 35.5% of its projects

Playwright (Python) in practice

Strengths

One loop over three engines

The README example calls <code>launch()</code>, <code>new_page()</code>, <code>goto()</code> and <code>screenshot()</code> inside a loop over Chromium, Firefox and WebKit. It saves one screenshot per engine, named with <code>browser_type.name</code>.

Blocking and asyncio versions of the same script

The README shows the example twice. The second version uses <code>async_playwright()</code>, awaits each browser call and runs under <code>asyncio.run(main())</code>.

Auto-waiting, by the maintainers' account

The site says actions wait until elements are actionable and that assertions retry until their conditions are met. The maintainers sum this up as "No artificial timeouts, no flaky tests."

Trace Viewer for failed runs

The site describes the Trace Viewer as a full timeline of a test run. It shows DOM snapshots, network requests, console logs and screenshots "at every step", so you can investigate failures without re-running.

Watch out for

Front page shows npm commands and camelCase names

The Python site's front page gives install commands such as <code>npm init playwright@latest</code> and <code>npm i -g @playwright/cli@latest</code>. It names locators <code>getByRole</code> and <code>getByLabel</code>, while the Python release notes write <code>get_by_role</code>.

Ubuntu 20.04 no longer supported

The v1.63.0 release notes announce that Ubuntu 20.04 is not supported anymore.

Frame locators without a selector can throw

<code>frame_locator()</code> called with no selector searches every frame in the subtree. The rest of the locator then resolves inside a single frame, and the release notes say "an error is thrown when it matches elements in several frames."

Screenshot a page in all three engines

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    for browser_type in [p.chromium, p.firefox, p.webkit]:
        browser = browser_type.launch()
        page = browser.new_page()
        page.goto('http://playwright.dev')
        page.screenshot(path=f'example-{browser_type.name}.png')
        browser.close()

More about Playwright (Python)

Agent Skills for it
  • : Skills, MCP servers, Custom Agents, Agents.md for SDKs to ground Coding Agents
  • : A refined collection of Hypervelocity Engineering components (instructions, prompts, agents, and skills) to start your project off right, or
  • : CLI for common Playwright actions. Record and generate Playwright code, inspect selectors and take screenshots.
  • playwright-recording: Record browser interactions as video using Playwright. Use for capturing demo videos, app walkthroughs, and UI flows for Remotion videos. Tr
  • playwright-interactive: Persistent browser and Electron interaction through `js_repl` for fast iterative UI debugging.
  • playwright-expert: Use when writing E2E tests with Playwright, setting up test infrastructure, or debugging flaky browser tests. Invoke to write test scripts,

See all

Packages around it
  • python-dotenv: Env vars from .env
  • pydantic: Data validation
  • requests: HTTP client
  • uvicorn: ASGI server
  • pillow: Image processing
  • fastapi: Web API framework
More in Scraping, browsers and parsing

Alternatives

Playwright (Python) This page

Apache-2.0Gid 7734.7M/wk

Selenium

Official Python bindings for browser automation and web scraping.

Apache-2.0Gid 616.5M/wk

Compare Playwright (Python) with another tool

Get started

Install it.

pip install playwright

Rules for your agent

Paste into AGENTS.md or CLAUDE.md
## Playwright (Python)
- For blocking code, follow the README: `from playwright.sync_api import sync_playwright` and `with sync_playwright() as p:`. For asyncio, use `async with async_playwright() as p:` and `await` the browser calls (`launch()`, `new_page()`, `goto()`, `screenshot()`, `close()`), run via `asyncio.run(main())`.
- Take Python syntax from the Python docs (https://playwright.dev/python/docs/intro) and API reference (https://playwright.dev/python/docs/api/class-playwright), e.g. `page.frame_locator().get_by_role("button").click()`. Do not copy the `getByRole`-style names or npm commands shown on the landing page.
- To filter to visible elements, use `locator.visible` (e.g. `page.locator("button").visible.click()`). The release notes call it the recommended replacement for the `:visible` CSS pseudo-class.
- To reach an element in an iframe without locating the iframe first, call `page.frame_locator()` with no selector. Make the rest of the locator specific enough to match in only one frame, or it throws.
- To record an aria snapshot and a screenshot on every action, start tracing with `context.tracing.start(snapshots=True, aria_snapshots=True, screen_snapshots=True)`.
- `http_credentials` accepts an array. The first entry matching the request origin is used, and an entry without an origin matches any request. Use `playwright codegen --http-credentials` to record against pages behind HTTP authentication.

AgentGid articles about Playwright (Python)

All guides