Playwright for Rust
Rust language bindings for Microsoft Playwright — the industry standard for cross-browser end-to-end testing.
Status: Pre-1.0, API stabilizing. See coverage trajectory for the path to v1.0.
🎯 Why playwright-rust?
Read our WHY.md to understand the vision, timing, and philosophy behind this project.
TL;DR: Rust is emerging as a serious web development language, with frameworks like Axum and Actix gaining traction. AI coding assistants are making Rust accessible to more developers. Test-Driven Development is experiencing a renaissance as the optimal way to work with AI agents. These trends are converging now, and they need production-quality E2E testing. playwright-rust fills that gap by bringing Playwright's industry-leading browser automation to the Rust ecosystem.
Roadmap and Goals
See Development Roadmap for plans and status of the development approach for playwright-rust.
Goal: Build this library to a production-quality state for broad adoption as @playwright/rust or playwright-rs. Provide official-quality Rust bindings for Microsoft Playwright, following the same architecture as playwright-python, playwright-java, and playwright-dotnet.
Quick Comparison: Python vs Rust
The API matches Playwright's cross-language conventions — if you know playwright-python, you know playwright-rust:
=
=
# Locator with auto-waiting
=
assert ==
# Response body access
=
=
use Playwright;
let pw = launch.await?;
let browser = pw.chromium.launch.await?;
let page = browser.new_page.await?;
page.goto.await?;
// Locator with auto-waiting
let heading = page.locator.await;
assert_eq!;
// Response body access
let resp = page.goto.await?.unwrap;
let data: Value = resp.json.await?;
browser.close.await?;
Coverage Trajectory
Each pre-v1.0 release targets 100% coverage of specific API classes:
| Class | Methods | Current (v0.11) | v0.12.0 |
|---|---|---|---|
| Locator | 55 | 100% | 100% |
| Response | 18 | 100% | 100% |
| Request | 19 | 100% | 100% |
| FrameLocator | 10 | 100% | 100% |
| Browser | 12 | 100% | 100% |
| Frame | 29 | 100% | 100% |
| JSHandle | 7 | 100% | 100% |
| Worker | 3 | 100% | 100% |
| WebSocket | 8 | 100% | 100% |
| ConsoleMessage | 6 | 100% | 100% |
| FileChooser | 4 | 100% | 100% |
| Selectors | 2 | 100% | 100% |
| WebError | 2 | 100% | 100% |
| Page | 67 | ~99% | 100% |
| BrowserContext | 32 | ~99% | 100% |
v0.12.0 targets full Python parity. v1.0.0 follows after multi-month dogfooding. See the full gap analysis for details.
How It Works
playwright-rust follows Microsoft's proven architecture for language bindings:
┌──────────────────────────────────────────────┐
│ playwright-rs (Rust API) │
│ - High-level, idiomatic Rust API │
│ - Async/await with tokio │
│ - Type-safe bindings │
└─────────────────────┬────────────────────────┘
│ JSON-RPC over stdio
┌─────────────────────▼────────────────────────┐
│ Playwright Server (Node.js/TypeScript) │
│ - Browser automation logic │
│ - Cross-browser protocol abstraction │
│ - Maintained by Microsoft Playwright team │
└─────────────────────┬────────────────────────┘
│ Native protocols
┌─────────────┼─────────────┐
▼ ▼ ▼
Chromium Firefox WebKit
This means:
- ✅ Full feature parity with Playwright (JS/Python/Java/.NET)
- ✅ Cross-browser support (Chromium, Firefox, WebKit)
- ✅ Automatic updates when Playwright server updates
- ✅ Minimal maintenance - protocols handled by Microsoft's server
- ✅ Production-tested architecture used by millions
API Design Philosophy
Following Playwright's cross-language consistency:
- Match Playwright API exactly - Same method names, same semantics
- Idiomatic Rust - Use Result, async/await, builder patterns where appropriate
- Type safety - Leverage Rust's type system for compile-time safety
- Auto-waiting - Built-in smart waits like other Playwright implementations
- Testing-first - Designed for reliable end-to-end testing
Installation
Add to your Cargo.toml:
[]
= "0.11" # Auto-updates to latest 0.11.x
= { = "1", = ["full"] }
See the CHANGELOG for version history and features.
Browser Installation (Required)
Browsers must be installed before use. Install once, then run tests as many times as needed.
# Install all browsers
# Or install specific browsers
In CI/CD: Add this to your GitHub Actions workflow:
- name: Install Playwright Browsers
run: npx playwright@1.58.2 install chromium firefox webkit --with-deps
Programmatic installation: For setup scripts, Docker images, or tools built on playwright-rs, you can install browsers from Rust code:
use install_browsers;
install_browsers.await?; // all browsers
install_browsers.await?; // specific browsers
Why version matters: The library bundles Playwright driver 1.58.2. Each release expects specific browser builds. Using the matching version ensures compatible browsers.
What happens if I don't install browsers? You'll get a helpful error message with the correct install command when trying to launch a browser.
Development
Prerequisites
- Rust 1.88+
- Node.js 18+ (for Playwright server and browser installation)
- tokio async runtime
Building from Source
# Clone repository
# Install pre-commit hooks
# Build
Installing Browsers
After building, install browsers as described in Browser Installation above:
The build script automatically downloads the Playwright driver to drivers/ (gitignored). CI handles browser installation automatically - see .github/workflows/test.yml.
Platform Support: ✅ Windows, macOS, Linux
Running Tests
This project uses cargo-nextest. Install once: cargo install cargo-nextest
Running Examples
See examples/ for usage examples.
Star History
Contributing
This project aims for production-quality Rust bindings matching Playwright's standards. Contributions should:
- Follow Playwright API conventions
- Include comprehensive tests
- Maintain type safety
- Document public APIs with examples
- Pass CI checks (fmt, clippy, tests)
License
Apache-2.0 (same as Microsoft Playwright)
Acknowledgments
- Microsoft Playwright Team - For the amazing browser automation framework
- playwright-python - API design reference