Playwright for Python is the Python port of Playwright, a library that automates Chromium, Firefox, and WebKit through a single API. It offers both a synchronous and an asynchronous interface, and runs browsers headless or headed on Linux, macOS, and Windows.
| Browser | Linux | macOS | Windows |
|---|---|---|---|
| Chromium | Yes | Yes | Yes |
| WebKit | Yes | Yes | Yes |
| Firefox | Yes | Yes | Yes |
Beyond scripted automation, the wider Playwright project targets testing and AI agents. Its test tooling waits for elements to be actionable before acting and retries assertions until conditions hold, gives each test an isolated browser context, and records traces with DOM snapshots, network requests, and console logs. For agents, it exposes pages as structured accessibility trees (roles, names, and refs) instead of screenshots, through an MCP server and a command-line interface for coding agents. The same library is also available for Node.js, .NET, and Java.
Features
- One API, three engines: Chromium, Firefox, and WebKit driven through the same calls
- Sync and async: a synchronous API and an asyncio-based API with matching capabilities
- Cross-platform: Linux, macOS, and Windows, headless or headed
- Auto-waiting: actions wait until elements are actionable and assertions retry until conditions are met
- Test isolation: each test gets a fresh browser context, with saved authentication state reusable across tests
- User-facing locators: selectors such as role, label, placeholder, and test ID instead of CSS paths
- Tracing: a timeline of execution with DOM snapshots, network requests, console logs, and screenshots
- Code generation: record browser actions and generate test code and assertions
- Agent access: structured accessibility snapshots, an MCP server, and a CLI for coding agents