Skip to main content
The Playwright CLI skill provides browser automation capabilities for web testing, form filling, screenshots, and data extraction. Automate browser interactions with a simple command-line interface.

Overview

This skill covers:
  • Core workflow - Navigate, interact, and snapshot pages
  • Form automation - Fill inputs, click buttons, submit forms
  • Testing - Verify functionality and capture states
  • Data extraction - Extract information from web pages
  • Screenshots & PDFs - Capture page content

Quick Start

playwright-cli install --skills
playwright-cli install-browser

Core Commands

playwright-cli open https://example.com
Opens the specified URL in the browser.

Interaction

# Click element by ref
playwright-cli click e3

# Double click
playwright-cli dblclick e7

# Type text
playwright-cli type "search query"

# Fill input field
playwright-cli fill e5 "[email protected]"

Snapshot & Extract

# Snapshot current page
playwright-cli snapshot

# Save snapshot to file
playwright-cli snapshot --filename=after-click.yaml

Capture Content

# Full page screenshot
playwright-cli screenshot

# Specific element
playwright-cli screenshot e5

# Save to file
playwright-cli screenshot --filename=page.png

Example: Form Submission

1

Navigate to Form

playwright-cli open https://example.com/form
playwright-cli snapshot
2

Fill Form Fields

# From snapshot, find element refs
playwright-cli fill e1 "[email protected]"
playwright-cli fill e2 "password123"
playwright-cli check e3  # Accept terms
3

Submit & Verify

playwright-cli click e4  # Submit button
playwright-cli snapshot
playwright-cli screenshot --filename=after-submit.png

Example: Multi-Tab Workflow

# Open first page
playwright-cli open https://example.com

# Open new tab
playwright-cli tab-new https://example.com/other

# List tabs
playwright-cli tab-list

# Switch back to first tab
playwright-cli tab-select 0

# Snapshot
playwright-cli snapshot

# Close current tab
playwright-cli tab-close

Storage Management

Cookies

playwright-cli cookie-list
playwright-cli cookie-list --domain=example.com
playwright-cli cookie-get session_id

Local & Session Storage

playwright-cli localstorage-list
playwright-cli localstorage-get theme
playwright-cli localstorage-set theme dark
playwright-cli localstorage-delete theme
playwright-cli localstorage-clear

State Persistence

# Save cookies, localStorage, sessionStorage
playwright-cli state-save
playwright-cli state-save auth.json

Network Mocking

# Block images
playwright-cli route "**/*.jpg" --status=404

# Mock API response
playwright-cli route "https://api.example.com/**" --body='{"mock": true}'

DevTools & Debugging

# Show all console messages
playwright-cli console

# Show only warnings
playwright-cli console warning

Browser Configuration

# Open with specific browser
playwright-cli open --browser=chrome https://example.com
playwright-cli open --browser=firefox https://example.com
playwright-cli open --browser=webkit https://example.com
playwright-cli open --browser=msedge https://example.com

Dialogs

# Accept dialog
playwright-cli dialog-accept

# Accept with text
playwright-cli dialog-accept "confirmation text"

# Dismiss dialog
playwright-cli dialog-dismiss

When to Use This Skill

Load this skill when:
  • Testing web applications
  • Filling forms automatically
  • Taking screenshots for documentation
  • Extracting data from web pages
  • Debugging browser interactions
  • Automating repetitive web tasks

Best Practices

Always snapshot after navigation or major interactions to get updated element references.
Use named sessions to run multiple browser instances simultaneously without conflicts.
Use state-save after logging in to reuse authentication across sessions.
Start tracing before reproducing issues to capture detailed execution traces.

Skill Structure

.github/skills/playwright-cli/
├── SKILL.md                      # Quick reference
└── references/
    ├── request-mocking.md       # Network interception
    ├── running-code.md          # Execute Playwright code
    ├── session-management.md    # Multi-session patterns
    ├── storage-state.md         # Cookies & localStorage
    ├── test-generation.md       # Generate tests
    ├── tracing.md              # Debug traces
    └── video-recording.md       # Record sessions

References

Use playwright-cli snapshot frequently to get updated element references. Element refs (like e5) change after page updates.

Build docs developers (and LLMs) love