playwright-cli

Automate browser interactions and generate Playwright tests through a command-line interface.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill playwright-cli-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-cli
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/playwright-cli
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill playwright-cli-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @playwright/cli, playwright, and includes references (resource) components.

What problem does it solve? Manually driving a browser to test web pages, debug failing Playwright tests, or record automation flows is slow and error-prone. This Skill lets you control a real browser session from the command line, inspect page state via accessibility snapshots, and automatically capture the equivalent Playwright TypeScript code for every action. ## Core Features & Use Cases - Interactive Browser Automation: Open pages, click, fill forms, drag, upload files, and manage tabs using element refs from accessibility snapshots. - Test Authoring and Healing: Run Playwright tests with --debug=cli, attach to the paused session, rehearse fixes, and copy the generated TypeScript directly into test files following a plan-generate-heal workflow. - Session, Storage, and Network Control: Run isolated named sessions, save and restore cookies/localStorage state, and mock or block network requests with route rules. - Use Case: A failing CI test needs diagnosis — run it with --debug=cli, attach playwright-cli to the paused browser, inspect the snapshot and console, rehearse the corrected locator, and paste the generated code back into the test. ## Quick Start Ask the AI to open a website with playwright-cli, take a snapshot of the page, and click a specific element by its ref.

Frequently Asked Questions about playwright-cli

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate browser interactions with playwright-cli?

Run playwright-cli open to launch a browser, then use snapshot to get element refs and commands like click, fill, and type to interact with them. Each action prints the equivalent Playwright TypeScript code you can reuse in tests.

How to debug a failing Playwright test with playwright-cli?

Run the test with PLAYWRIGHT_HTML_OPEN=never npx playwright test --debug=cli in the background, then attach with playwright-cli attach using the printed session name. The test pauses at the start so you can step through, inspect snapshots, and rehearse fixes.

Can playwright-cli run multiple isolated browser sessions?

Yes, use the -s flag to create named sessions with independent cookies, storage, cache, and tabs. List them with playwright-cli list and clean up with close, close-all, or kill-all for stale processes.

Does playwright-cli support mocking network requests?

Yes, the route command intercepts URL patterns to return custom status codes, JSON bodies, or headers, and unroute removes them. For conditional logic or response modification, use run-code with page.route in arbitrary Playwright code.

How do I save and reuse login state in Playwright?

After logging in, run playwright-cli state-save to write cookies and localStorage to a JSON file. Later, state-load restores that state so subsequent sessions skip the login flow entirely.

What are the limitations of playwright-cli video recording?

Video recording outputs WebM files and adds slight overhead to automation, with large recordings consuming significant disk space. For debugging with DOM snapshots and network details, tracing is a better fit than video.