playwright-python

A Python library that automates Chromium, Firefox, and WebKit through one reliable, auto-waiting API.

Library
PyPI
v1.62.0
14,981stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
92/100Excellent
Development Activity96
Maintenance100
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
89/100Excellent
Architecture90
Code Quality92
Innovation90
Learning Curve85

Playwright for Python is Microsoft’s official Python binding for the Playwright browser automation engine, letting developers drive Chromium, Firefox, and WebKit from a single, consistent API. It’s built for end-to-end testing and web scraping/automation workloads that need to reliably interact with real, modern web pages rather than a simplified DOM.

Under the hood, the Python package is a thin, fully-typed client over a bundled Node.js driver process: every call — clicking, navigating, waiting for network activity — is proxied over a message channel to the actual browser-automation engine, while the Python-facing API exposes both a synchronous surface (sync_playwright()) and an asyncio-based surface (async_playwright()) generated from the same underlying implementation. That means teams can pick whichever style fits their codebase (plain pytest scripts vs. asyncio-based scrapers) without giving up feature parity or auto-waiting semantics.

The library ships with built-in auto-waiting (actions wait for elements to be actionable before proceeding), network interception and mocking, multiple browser contexts for isolated sessions, and codegen/trace-viewer tooling exposed through its bundled CLI (playwright install, playwright codegen) for scaffolding and debugging tests.

What You Get

  • A single API that drives Chromium, Firefox, and WebKit without browser-specific code paths
  • Both a synchronous API (sync_playwright) and an asyncio-native API (async_playwright) generated from one shared implementation
  • Auto-waiting actions that wait for elements to become actionable, cutting down on manual sleeps and flaky selectors
  • Network interception and request/response mocking via route handlers
  • Isolated, disposable browser contexts for parallel, state-free test sessions
  • A bundled CLI (playwright install, playwright codegen, trace viewer) for driver setup, test recording, and debugging

Common Use Cases

  • End-to-end test suites for web applications, typically wired into pytest via the pytest-playwright plugin
  • Web scraping and data extraction from JavaScript-heavy pages that require a real rendering engine
  • Automated visual regression testing using screenshot comparisons across Chromium/Firefox/WebKit
  • Scripted browser workflows such as form submission, login flows, and multi-step user journeys
  • Cross-browser compatibility verification for web apps without maintaining separate browser-specific test code

Under The Hood

Architecture The Python bindings wrap a bundled Node.js driver process launched via playwright/_impl/_driver.py’s compute_driver_executable(), communicating over a stdio-based message channel (playwright/_impl/_connection.py) that serializes calls to the driver process and receives events back as they occur. The public-facing modules (playwright/sync_api, playwright/async_api) are thin, code-generated facades over the shared low-level implementation objects in playwright/_impl/ (_browser.py, _browser_context.py, _page.py, _frame.py, and others), mapped through _impl_to_api_mapping.py so one core implementation backs both API styles. The synchronous facade achieves blocking calls by running the actual async event loop on a background thread and switching context with greenlets (_greenlets.py), so callers get synchronous-looking code while all real browser protocol traffic stays fully async underneath. This is a cleanly layered design: the Python-side objects are essentially typed proxies over remote state living in the driver process, so a change to that message-channel protocol would ripple through every _impl class, but the public API layer itself stays decoupled from that churn via the generated mapping layer.

Tech Stack The package itself is pure Python (>=3.10) with a minimal runtime dependency footprint — pyee for the event-emitter pattern used in the connection/channel messaging layer, and greenlet for the sync/async context-switching bridge — while the actual browser engines are delegated to a versioned Node.js driver (pinned via DRIVER_VERSION/NODE_VERSION) built from Microsoft’s own playwright-core npm package and bundled per-platform at install time through setup.py’s custom wheel logic, covering macOS/Linux/Windows across x86_64/arm64. Packaging uses setuptools with setuptools-scm for version derivation and auditwheel for manylinux compliance, and the playwright console-script entry point simply shells out to the bundled Node.js driver binary.

Code Quality Testing is extensive: a large tests/ suite is split into parallel sync/ and async/ variants plus shared common/ fixtures, run under pytest with asyncio_mode=auto, alongside per-engine golden-image directories (golden-chromium, golden-firefox, golden-webkit) for reference-image comparisons, all exercised across platforms in CI (.github/workflows/ci.yml and Azure Pipelines). Static analysis is comprehensive and enforced via pre-commit hooks covering black, isort, flake8, mypy (with disallow_untyped_defs and warn_redundant_casts), and a local pyright hook, alongside a custom license-header check. Error handling is explicit and typed through a dedicated _errors.py module (TargetClosedError, rewrite_error) rather than broad exception swallowing.

API Design The library’s core design bet is generating both a synchronous API (sync_playwright()) and an asyncio-native API (async_playwright()) from one shared implementation and protocol definition, via scripts/generate_sync_api.py and scripts/generate_async_api.py producing each API’s _generated.py. Rather than forcing developers into either a blocking (Selenium-style) or async-only client, Playwright gives both styles identical semantics and feature parity — auto-waiting, network interception, and multi-browser support — from a single source of truth, reducing the API-surface duplication and drift that hand-maintained sync/async twins usually accumulate.

Used by 13 apps in this directory

Python
100%
Apache 2.0

Agno

Devops · AI Development · Automation

42,074

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python100%
Updated yesterday
Python
62%
MIT

AutoGen

AI Development · Automation

60,839

Build autonomous and human-in-the-loop multi-agent AI systems with a layered, event-driven Python and .NET framework pioneered at Microsoft Research.

View details
56
Repo Health
78
Technical
73
Dependency
Built with
Python62%
C#25%
TypeScript12%
Updated 4 months ago
Python
67%
Other

AutoGPT

Automation · Productivity · AI Assistants

187,177

Build, deploy, and run autonomous AI agents that automate complex multi-step workflows using a visual block-based graph editor.

View details
93
Repo Health
78
Technical
66
Dependency
Built with
Python67%
TypeScript32%
Updated today
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,816

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust28%
C23%
Updated yesterday
Python
67%
Apache 2.0

GPT Researcher

Productivity · AI Assistants

29,319

The pioneering open-source autonomous AI agent that conducts deep, multi-source research and produces citation-backed reports exceeding 2,000 words — faster and more reliably than any human researcher.

View details
90
Repo Health
91
Technical
63
Dependency
Built with
Python67%
TypeScript20%
Updated 1 weeks ago
Python
64%
Other

Keep

Devops · Automation · Monitoring

12,290

The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.

View details
91
Repo Health
79
Technical
66
Dependency
Built with
Python64%
TypeScript36%
Updated yesterday
Python
37%
Other

Open WebUI

AI Assistants · AI Agents

151,143

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
91
Repo Health
75
Technical
66
Dependency
Built with
Python37%
Svelte34%
JavaScript21%
Updated yesterday
TypeScript
94%
Other

OpenHands

AI Code Assistants · AI Development

86,377

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
70
Dependency
Built with
TypeScript94%
Updated today
HTML
36%

OpenPanel

Hosting Control Panel · Devops

743

Docker-powered web hosting control panel that gives every user a fully isolated environment with dedicated web server, database, and networking — VPS-grade security on shared hardware.

View details
81
Repo Health
75
Technical
63
Dependency
Built with
HTML36%
Go32%
TypeScript25%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search