# Playwright (Python) — card for AI agents

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

Category: Scraping, browsers and parsing · PyPI package `playwright` · latest version 1.64.1 (checked 2026-11-01)
Install: `pip install playwright`
License: Apache-2.0 (permissive)

In your own product (generator, app, hosted service): **yes**. Permissive license: ship it inside your own product, closed or open source, and keep its license and copyright notice.

## Rules for AI agents (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.

## Agent Skills for it
- Official: microsoft/skills (213 skills): `npx skills add microsoft/skills`
- Official: microsoft/hve-core (97 skills): `npx skills add microsoft/hve-core`
- Official: microsoft/playwright-cli (2 skills): `npx skills add microsoft/playwright-cli`
- playwright-recording from OpenMontageInc/OpenMontage: `npx skills add OpenMontageInc/OpenMontage --skill playwright-recording`
- playwright-interactive from openai/skills: `npx skills add openai/skills --skill playwright-interactive`
- playwright-expert from Jeffallan/claude-skills: `npx skills add Jeffallan/claude-skills --skill playwright-expert`
- playwright-skill from tech-leads-club/agent-skills: `npx skills add tech-leads-club/agent-skills --skill playwright-skill`
- playwright-best-practices from midudev/autoskills: `npx skills add midudev/autoskills --skill playwright-best-practices`
- playwright-skill from zebbern/claude-code-guide: `npx skills add zebbern/claude-code-guide --skill playwright-skill`

## What it is
- Playwright for Python is the "Python version of the Playwright testing and automation library", per its GitHub repository. The repository was created on 2020-07-01 and is Apache-2.0 licensed. The README links to a PyPI page for `playwright`. It describes the library as a way to automate Chromium, Firefox and WebKit "with a single API". A table in the README marks all three engines as supported on Linux, macOS and Windows.
- You import either `playwright.sync_api` or `playwright.async_api`. Then you launch a browser type, open a page and act on it. The README example runs the same calls in a loop over `p.chromium`, `p.firefox` and `p.webkit`. The website pitches the project for end-to-end testing. It lists auto-waiting, a fresh browser context per test, a test generator and a Trace Viewer.
- A section of the site titled "Built for AI agents" describes two more pieces. One is an MCP server that gives agents browser control "through structured accessibility snapshots". The other is a "token-efficient" CLI with installable skills for coding agents. The project is aimed at people who write browser tests and automation scripts, and at people connecting browsers to AI agents.

## Caveats
- Front page shows npm commands and camelCase names: The Python site's front page gives install commands such as `npm init playwright@latest` and `npm i -g @playwright/cli@latest`. It names locators `getByRole` and `getByLabel`, while the Python release notes write `get_by_role`.
- 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: `frame_locator()` 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."

## Numbers (AgentGid data)
- Gid Score: 77.2 (#153 of all tools, 6 of 141 in its category)
- Used in 76 public projects set up for AI coding agents (1.2%)
- Downloads last week: 34,673,841 (as of 2026-11-24), +18.0% over 4 weeks
- GitHub stars: 15,125 (as of 2026-11-24)
- Last push: 2026-11-23

## Often used with
python-dotenv 64.5%, Uvicorn 52.6%, Pillow 44.7%, Pydantic 43.4%, FastAPI 40.8%, Requests 39.5%

## Checked alternatives (same job)
- Selenium: https://agentgid.com/tools/selenium/agent.md

## Links
- AgentGid page: https://agentgid.com/tools/playwright/
- Homepage: https://github.com/Microsoft/playwright-python
- Repository: https://github.com/microsoft/playwright-python
- Source: https://github.com/microsoft/playwright-python#readme
- Source: https://github.com/microsoft/playwright-python
- Source: https://github.com/microsoft/playwright-python/releases
- Source: https://playwright.dev/python/

---
AgentGid's catalog is curated: every entry was checked against the maker's official pages (registry, repository, license and pricing pages) on the date shown; a license value shows the quote it stands on wherever AgentGid has one. Usage numbers come from AgentGid's own scan of public repositories set up for AI coding agents. Claims by makers are reported, not tested by AgentGid.
