Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Playwright CLI

$ playwright Official Med Risk
Microsoft · Browser & Web · Apache-2.0 · macos / linux / windows

Playwright 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.

FCRS-1.0 Score
85 /100
Good
Medium Confidence
Zero-Friction Install
npm install -D @playwright/test
CLI vs MCP Decision Hybrid (CLI + MCP)

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

✓ JSON Output
— Field Filtering
✓ Non-Interactive
— Dry-Run
— Read-Only Mode
✓ NO_COLOR Clean
— Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 20 / 25

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=json provides clean structured diagnostics
  • GUI subcommands (--ui, codegen, show-report) block non-TTY agents
Trust & Safety 20 / 25

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
Setup & Portability 12 / 15

Cross-platform via npm/PyPI, though requires downloading browser binaries (playwright install) and OS shared libraries on minimal Linux containers.

  • Requires playwright install browser binary download (~400 MB)
Utility & Efficiency 14 / 15

Gold standard for verifying real browser rendering, screenshots, and E2E suites.

  • Full Chromium/Firefox/WebKit rendering and trace generation
Maintenance & Lineage 10 / 10

Official Microsoft project (microsoft/playwright) under Apache-2.0.

  • Official microsoft/playwright repository
Docs & Verifiability 9 / 10

Detailed Playwright CLI and test reporter documentation.

  • Official docs at playwright.dev/docs/test-cli

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

No CLI credential required; browser storageState JSON files are user-managed locally if testing authenticated apps.

Side Effects
Read-Only Local Write Remote Write
Cost & Quotas

Apache-2.0 open-source and free; browser binaries require ~300–500 MB local disk cache.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# 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

Run E2E tests with JSON reporter
npx playwright test --reporter=json

Emits machine-readable test pass/fail results and failure stacks without HTML report server hanging.

Capture a headless page screenshot
npx playwright screenshot http://localhost:4321 preview.png

Quickly renders a local page to PNG for visual verification.

Controlled Writes & Previews

Export a page as PDF locally
npx playwright pdf http://localhost:4321 page.pdf

Writes a rendered PDF artifact to the local workspace.

Strengths for Agents

  • + --reporter=json delivers deterministic pass/fail diagnostics for coding-agent fix loops.
  • + One-line screenshot and pdf subcommands 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=json or CI=1 is set.
  • ! Heavy disk footprint when installing Chromium/WebKit binaries.

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI