playwright-cli

Automate browser interactions and generate Playwright tests via the playwright-cli command line.

1|Updated May 25, 2020
One-click install
npx skills add https://github.com/titaneric/dotfiles --skill playwright-cli-titaneric
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: playwright-cli
Source: https://github.com/titaneric/dotfiles/tree/main/dot_agents/skills/playwright-cli
Command: npx skills add https://github.com/titaneric/dotfiles --skill playwright-cli-titaneric

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @playwright/cli, 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 an AI agent control a real browser through the playwright-cli command line, turning every action into reusable Playwright TypeScript code. ## Core Features & Use Cases - Interactive Browser Automation: Open pages, click, fill forms, drag, upload files, manage tabs, and inspect accessibility snapshots using element refs. - Test Authoring and Healing: Run tests with --debug=cli, attach to the paused session, rehearse fixes live, and copy the generated TypeScript back into spec files following a plan-generate-heal workflow. - Network, Storage, and Session Control: Mock requests, manage cookies and localStorage, run multiple isolated named sessions, and attach to running Chrome or Edge instances via CDP. - Use Case: A failing CI test is debugged by running it with --debug=cli, attaching playwright-cli to the paused page, inspecting the snapshot and console, fixing the locator, and rerunning the test until green. ## Quick Start Use the playwright-cli skill to open https://example.com, take a snapshot, and click the sign-in button.

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 from the command line with Playwright?

Use playwright-cli to open a browser, navigate with goto, take a snapshot to get element refs, then run commands like click, fill, and press against those refs. Each action prints the equivalent Playwright TypeScript you can reuse in tests.

How to debug a failing Playwright test interactively?

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. Inspect the snapshot, console, and network requests, rehearse the fix, and paste the generated code into the test.

Can playwright-cli connect to an already running Chrome or Edge browser?

Yes, use playwright-cli attach --cdp=chrome or --cdp=msedge after enabling remote debugging in the browser, or attach to any CDP endpoint URL. Detach later with playwright-cli detach without closing the external browser.

How do I mock network requests in Playwright from the CLI?

Use playwright-cli route with a URL pattern plus --status, --body, or --header options to intercept requests. For conditional logic or response modification, use run-code with page.route to fulfill, modify, or abort requests programmatically.

Does playwright-cli support multiple isolated browser sessions?

Yes, the -s flag creates named sessions with independent cookies, storage, cache, and tabs. List them with playwright-cli list, stop one with -s=name close, or stop everything with close-all or kill-all.

What are the limitations of playwright-cli video recording and tracing?

Recording and tracing add overhead to automation and can consume significant disk space. Traces capture DOM snapshots and network detail for debugging, while video produces WebM files suited for demos and documentation.