agent2playwright
Convert browser-agent trajectories into certified deterministic pytest-Playwright tests.
agent2playwright (CLI: a2pw) compiles noisy browser-agent runs — browser-use, Playwright MCP, workflow-use style histories — into CI-ready pytest-Playwright suites using multi-run consensus, Playwright locator policy, secret sanitization, and a certification scorecard. No LLM is required at replay time.
browser-use / MCP / OTIR runs
│
▼
adapt → OTIR (open IR)
│
▼
clean → consensus → harden → sanitize → assert
│
▼
pytest-playwright + POM + SCORECARD.md
Install
pip install agent2playwright
# or from source:
pip install -e ".[dev]"
python -m playwright install chromium
Quickstart
# Compile 3 agent runs of the same task into one certified test
a2pw compile \
examples/trajectories/login_run_a.json \
examples/trajectories/login_run_b.json \
examples/trajectories/login_run_c.json \
-o a2pw-out \
--test-name test_login_dashboard
from agent2playwright import compile_trajectories
from agent2playwright.adapters import detect_and_load
from agent2playwright.models import CompileOptions
runs = [detect_and_load(p) for p in [
"examples/trajectories/login_run_a.json",
"examples/trajectories/login_run_b.json",
"examples/trajectories/login_run_c.json",
]]
result = compile_trajectories(runs, CompileOptions(test_name="test_login_dashboard"))
print(result.scorecard.summary)
Path("test_login_dashboard.py").write_text(result.test_code)
Why agent2playwright?
| Capability | Raw agent dump | agent2playwright |
|---|---|---|
| Multi-run consensus (drop exploration noise) | No | Yes |
| CI certification scorecard | No | Yes |
| Playwright locator policy (role/label/test id) | Rare | Enforced |
| Intent → web-first assertions | Rare | Yes |
Secret → A2PW_PASSWORD env vars |
Sometimes | Always |
| pytest-Playwright + Page Object Model | Rare | Default |
Live verification
python benchmarks/live_multisite.py
| Site | Live | Score |
|---|---|---|
| SauceDemo login | 3/3 | 98.7 |
| SauceDemo checkout | 3/3 | 89.7 |
| the-internet login | 3/3 | 98.7 |
| the-internet dropdown | 3/3 | 85.0 |
| the-internet dynamic loading | 3/3 | 98.7 |
| Playwright TodoMVC | 3/3 | 98.7 |
How do I convert browser-use agent history to Playwright pytest?
- Save agent history JSON from browser-use (or export OTIR).
- Run the same task 2–3 times for consensus.
- Compile:
a2pw compile run_a.json run_b.json run_c.json -o tests_out --test-name test_flow
export A2PW_PASSWORD='...'
pytest tests_out/tests --browser chromium
How is agent2playwright different from browse-to-test / recast / flow2skill?
| Tool | Focus |
|---|---|
| agent2playwright | Agent trajectories → certified pytest-Playwright via consensus + scorecard |
| browse-to-test | Recording/automation data → scripts (broader converter) |
| recast | Agent recordings → static Playwright (often TS-first) |
| flow2skill | Human Playwright codegen → skill + pytest proof |
Use agent2playwright when you already have browser-agent runs and need CI-stable pytest with a fail/pass certification gate.
Can I compile multiple agent trajectories into one stable test?
Yes. Pass multiple JSON files to a2pw compile. Steps must agree across enough runs (default 67%) to survive consensus. Retries, wrong clicks, and one-off detours are dropped.
OTIR
Open Trajectory Intermediate Representation — driver-agnostic JSON (src/agent2playwright/schema/otir.schema.json).
a2pw adapt raw-browser-use.json -o otir.json
a2pw certify otir.json
CLI
a2pw adapt <trajectory.json> -o otir.json
a2pw compile <run1.json> [run2.json ...] -o out/ --require-cert
a2pw certify <trajectory.json>
Exit codes: 0 certified, 1 compiled but not certified, 2 hard failure with --require-cert.
License
Apache-2.0
Metadata
Release files for agent2playwright 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agent2playwright-0.1.0.tar.gz | 33.8 kB | Without provenance | Details for agent2playwright-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agent2playwright-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for agent2playwright-0.1.0-py3-none-any.whl |
Total release size: 65.8 kB
Release files / agent2playwright-0.1.0.tar.gz
| Download URL | agent2playwright-0.1.0.tar.gz |
|---|---|
| Size | 33.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69dbcc712a420065e5ec353d9db81483b3e6011f34170131a4de45bf96e42606
|
|
BLAKE2b-256 checksum How to use checksums |
e7715bd656d809f7c9049ef4f0a3f997a1fb7dc6b3f004259f80379890c416e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Release files / agent2playwright-0.1.0-py3-none-any.whl
| Download URL | agent2playwright-0.1.0-py3-none-any.whl |
|---|---|
| Size | 31.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50a34d763a1cb514b6f2f468db505428d74beec7d86dbf2bee5214ae86c9457d
|
|
BLAKE2b-256 checksum How to use checksums |
4a8ac1e1e63870b8d031f7ee8a10c4e6e2057ec44458a353e94f4b40c61af0e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.4
|
Security for agent2playwright 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.