Playwright CLI
$ playwright Official Med RiskPlaywright CLI drives Chromium, Firefox, and WebKit headlessly for end-to-end verification, trace collection, screenshot/PDF export, and structured --reporter=json test output inside CI and coding-agent loops.
npm install -D @playwright/test Use playwright test --reporter=json when running deterministic test suites; use Playwright MCP (or dedicated browser subagents) for multi-step interactive DOM exploration.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --reporter=json and headless screenshot/PDF subcommands, though default HTML reporter or --ui/codegen modes can block headless shells if invoked carelessly.
playwright test --reporter=jsonprovides clean structured diagnostics- GUI subcommands (
--ui,codegen,show-report) block non-TTY agents
Runs locally without cloud credentials, though headless browsers execute arbitrary remote JS and can interact with authenticated web apps if given session state.
- No external API keys needed; browser executes untrusted page scripts
Cross-platform via npm/PyPI, though requires downloading browser binaries (playwright install) and OS shared libraries on minimal Linux containers.
- Requires
playwright installbrowser binary download (~400 MB)
Gold standard for verifying real browser rendering, screenshots, and E2E suites.
- Full Chromium/Firefox/WebKit rendering and trace generation
Official Microsoft project (microsoft/playwright) under Apache-2.0.
- Official
microsoft/playwrightrepository
Detailed Playwright CLI and test reporter documentation.
- Official docs at playwright.dev/docs/test-cli
Security, Auth & Guardrails
No CLI credential required; browser storageState JSON files are user-managed locally if testing authenticated apps.
Apache-2.0 open-source and free; browser binaries require ~300–500 MB local disk cache.
# Playwright CLI Agent Rules - Always pass `--reporter=json` or `--reporter=line` (avoid `--reporter=html` which starts a blocking local web server on failure). - Never run `playwright codegen` or `--ui` inside headless agent shells. - Avoid pointing screenshot/script runs at untrusted external URLs with local auth cookies attached.
Agent-Ready Command Recipes
Safe Read-Only Queries
npx playwright test --reporter=json
Emits machine-readable test pass/fail results and failure stacks without HTML report server hanging.
npx playwright screenshot http://localhost:4321 preview.png
Quickly renders a local page to PNG for visual verification.
Controlled Writes & Previews
npx playwright pdf http://localhost:4321 page.pdf
Writes a rendered PDF artifact to the local workspace.
Strengths for Agents
- +
--reporter=jsondelivers deterministic pass/fail diagnostics for coding-agent fix loops. - + One-line
screenshotandpdfsubcommands work without writing test boilerplate. - + Cross-browser rendering fidelity backed by Microsoft.
Caveats & Pitfalls
- ! Default HTML reporter launches a blocking HTTP server on test failure unless
--reporter=jsonorCI=1is set. - ! Heavy disk footprint when installing Chromium/WebKit binaries.