Skip to main content
AI/MLWaterplanAI

playwright-cli

Browser automation via playwright-cli. Token-efficient alternative to Playwright MCP - uses CLI commands through Bash instead of MCP tool schemas. Supports navigation, interaction, screenshots, video recording, and session management. Triggers on keywords: browser, e2e, playwright, screenshot, navigate, click, type, test browser, visual test

Stars
31
Source
WaterplanAI/agentic-config
Updated
2026-05-25
Slug
WaterplanAI--agentic-config--playwright-cli
View on GitHubRaw SKILL.md

// install — copy + paste into any project

mkdir -p .claude/skills && curl -fsSL https://raw.githubusercontent.com/WaterplanAI/agentic-config/HEAD/plugins/ac-qa/skills/ac-qa/playwright-cli/SKILL.md -o .claude/skills/playwright-cli.md

Drops the SKILL.md into .claude/skills/playwright-cli.md. Works with Claude Code, Cursor, and any agent that loads SKILL.md files from .claude/skills/.

Playwright CLI Browser Automation

Browser automation using playwright-cli - a token-efficient CLI alternative to Playwright MCP.

Prerequisites

  • Node.js >= 18
  • Global install: npm install -g @playwright/cli@latest
  • Browser: playwright-cli install-browser

Quick Reference

Navigation

playwright-cli open https://example.com          # Open URL (creates default session)
playwright-cli -s=mytest open https://example.com # Named session
playwright-cli goto https://example.com/page      # Navigate within session
playwright-cli go-back                             # Browser back
playwright-cli go-forward                          # Browser forward
playwright-cli reload                              # Reload page
playwright-cli close                               # Close session

Page Inspection

playwright-cli snapshot                  # Accessibility snapshot (like browser_snapshot)
playwright-cli screenshot                # Take PNG screenshot
playwright-cli screenshot --output ./out.png  # Save to specific path
playwright-cli pdf --output ./page.pdf   # Save page as PDF

Interaction

playwright-cli click "Button Text"       # Click by text
playwright-cli click "#submit-btn"       # Click by selector
playwright-cli fill "#email" "user@example.com"  # Fill input field
playwright-cli type "Hello world"        # Type text into focused element
playwright-cli select "#dropdown" "option1"      # Select dropdown option
playwright-cli hover "#menu-item"        # Hover over element
playwright-cli check "#checkbox"         # Check a checkbox
playwright-cli uncheck "#checkbox"       # Uncheck a checkbox
playwright-cli dblclick "#element"       # Double-click
playwright-cli upload "#file-input" ./file.txt   # Upload file

Keyboard & Mouse

playwright-cli press Enter               # Press key
playwright-cli press Control+a           # Key combination
playwright-cli keydown Shift             # Hold key
playwright-cli keyup Shift               # Release key

Tabs

playwright-cli tab-list                  # List open tabs
playwright-cli tab-new https://example.com  # Open new tab
playwright-cli tab-select 1              # Switch to tab by index
playwright-cli tab-close                 # Close current tab

Session Management

playwright-cli -s=session1 open https://example.com  # Create named session
playwright-cli -s=session1 snapshot      # Use existing session
playwright-cli list                      # List active sessions
playwright-cli close-all                 # Close all sessions
PLAYWRIGHT_CLI_SESSION=session1 playwright-cli snapshot  # Env var session

Video Recording

playwright-cli video-start               # Start recording
playwright-cli video-stop                # Stop recording (saves file)

Developer Tools

playwright-cli console                   # Get console messages
playwright-cli network                   # Get network requests
playwright-cli run-code "document.title" # Execute JavaScript in page

Tracing

playwright-cli tracing-start             # Start trace capture
playwright-cli tracing-stop --output trace.zip  # Stop and save trace

Network Mocking

playwright-cli route "**\/api\/*" --status 200 --body '{"ok":true}'
playwright-cli route-list                # List active routes
playwright-cli unroute "**\/api\/*"      # Remove route

Storage State

playwright-cli state-save --output state.json    # Save cookies + storage
playwright-cli state-load --input state.json     # Restore state

Window

playwright-cli resize 1920 1080          # Set viewport size

Dialog Handling

playwright-cli dialog-accept             # Accept alert/confirm/prompt
playwright-cli dialog-dismiss            # Dismiss dialog

Configuration

Optional playwright-cli.json in project root:

{
  "browserName": "chromium",
  "isolated": true,
  "launchOptions": {
    "headless": false
  },
  "contextOptions": {
    "viewport": { "width": 1920, "height": 1080 }
  },
  "saveVideo": {
    "width": 1920,
    "height": 1080
  },
  "outputDir": "./outputs/e2e"
}

Headed Mode

playwright-cli --headed open https://example.com  # Visible browser window

Key Differences from Playwright MCP

Aspect MCP CLI
Token usage Heavy (page snapshots + tool schemas) Light (shell commands)
Integration MCP config per AI tool Single global npm install
State MCP server process Persistent named sessions
Video Automatic via --save-video Explicit video-start/video-stop
Screenshots browser_take_screenshot tool playwright-cli screenshot
Snapshots browser_snapshot tool playwright-cli snapshot

Reference Documentation