new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Playwright · all subjects

playwright-cli

20 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

playwright-cli navigation commands

The following commands navigate pages: playwright-cli go-back goes back; playwright-cli go-forward goes forward; playwright-cli reload reloads the page.

playwright-cli purpose and design

playwright-cli is a command-line interface for browser automation designed for coding agents. It provides token-efficient browser control through concise CLI commands and installable skills, making it ideal for agents that need to balance browser automation with large codebases and reasoning within limited context windows.

playwright-cli vs Playwright MCP

playwright-cli is best for coding agents (Claude Code, GitHub Copilot, etc.) that favor token-efficient, skill-based workflows where CLI commands avoid loading large tool schemas and verbose accessibility trees into model context. MCP is best for specialized agentic loops that benefit from persistent state and iterative reasoning over page structure, such as exploratory automation or long-running autonomous workflows.

playwright-cli global installation

To install playwright-cli globally, run: npm install -g @playwright/cli@latest, then verify with playwright-cli --help.

playwright-cli local installation

To install @playwright/cli as a local dependency, run: npm install -D @playwright/cli@latest, then use: npx playwright cli --help.

Install playwright-cli skills for coding agents

Coding agents can use locally installed skills for richer context about available commands. Run: playwright-cli install --skills. To share skills across all projects, use: playwright-cli install --skills -g to install into home directory (~/.claude/skills or ~/.agents/skills with --skills=agents flag).

playwright-cli core interaction commands

The following commands interact with pages: playwright-cli open [url] opens browser and optionally navigates to url; playwright-cli goto <url> navigates to a url; playwright-cli click <ref> [button] clicks an element; playwright-cli type <text> types into editable element; playwright-cli fill <ref> <text> fills text into editable element; playwright-cli select <ref> <value> selects option in dropdown; playwright-cli check <ref> checks checkbox or radio button; playwright-cli uncheck <ref> unchecks checkbox; playwright-cli hover <ref> hovers over element; playwright-cli drag <startRef> <endRef> drags and drops between elements; playwright-cli upload <files...> uploads one or multiple files; playwright-cli close closes the page.

playwright-cli element targeting methods

Elements can be targeted using element refs from snapshots (e.g., e15), CSS selectors (e.g., #main > button.submit), role selectors (e.g., role=button[name=Submit]), or chained selectors combining multiple targets (e.g., #footer >> role=button[name=Submit]).

playwright-cli screenshot and snapshot commands

The following commands capture page state: playwright-cli snapshot captures page snapshot with element refs; playwright-cli snapshot --filename=f saves snapshot to specific file; playwright-cli screenshot captures screenshot of current page; playwright-cli screenshot [ref] captures screenshot of specific element; playwright-cli screenshot --filename=f saves with specific filename; playwright-cli screenshot --hires captures using device pixels; playwright-cli pdf saves page as PDF.

playwright-cli keyboard and mouse commands

The following commands control keyboard and mouse: playwright-cli press <key> presses a key (e.g. Enter, ArrowLeft); playwright-cli keydown <key> key down; playwright-cli keyup <key> key up; playwright-cli mousemove <x> <y> moves mouse; playwright-cli mousedown [button] mouse button down; playwright-cli mouseup [button] mouse button up; playwright-cli mousewheel <dx> <dy> scrolls.

playwright-cli tab management commands

The following commands manage tabs: playwright-cli tab-list lists all tabs; playwright-cli tab-new [url] creates new tab; playwright-cli tab-select <index> selects a tab; playwright-cli tab-close [index] closes a tab.

playwright-cli network commands

The following commands manage network requests: playwright-cli requests lists network requests since page load; playwright-cli request <num> shows full details of single request; playwright-cli route <pattern> [opts] mocks network requests; playwright-cli route-list lists active routes; playwright-cli unroute [pattern] removes routes.

playwright-cli storage commands

The following commands manage storage: playwright-cli state-save [filename] saves storage state (cookies, localStorage); playwright-cli state-load <filename> loads storage state. Cookie commands: playwright-cli cookie-list [--domain] lists cookies; playwright-cli cookie-get <name> gets cookie; playwright-cli cookie-set <name> <val> sets cookie; playwright-cli cookie-delete <name> deletes cookie; playwright-cli cookie-clear clears all cookies. localStorage commands: playwright-cli localstorage-list lists entries; playwright-cli localstorage-get <key> gets value; playwright-cli localstorage-set <k> <v> sets value; playwright-cli localstorage-delete <k> deletes entry; playwright-cli localstorage-clear clears all.

playwright-cli DevTools commands

The following commands access DevTools: playwright-cli console [min-level] lists console messages; playwright-cli eval <func> [ref] evaluates JavaScript on page; playwright-cli run-code <code> runs Playwright code snippet; playwright-cli tracing-start starts trace recording; playwright-cli tracing-stop stops trace recording; playwright-cli video-start starts video recording; playwright-cli video-chapter <title> adds chapter marker to video; playwright-cli video-stop --filename=f stops video recording.

playwright-cli session management

The CLI keeps browser profile in memory by default with cookies and storage state preserved between calls within a session but lost when browser closes. Use --persistent to save profile to disk. Named sessions allow running multiple browser instances for different projects. Commands: playwright-cli list lists all sessions; playwright-cli close-all closes all browsers; playwright-cli kill-all forcefully kills all browser processes; playwright-cli -s=name delete-data deletes user data for named session. Sessions can be specified via PLAYWRIGHT_CLI_SESSION environment variable.

playwright-cli monitoring dashboard

Use playwright-cli show to open visual dashboard for observing and controlling all running browser sessions. The dashboard provides: session grid showing all active sessions grouped by workspace with live screencast preview, session name, current URL, and page title where clicking any session zooms in; session detail with live view of selected session including tab bar, navigation controls, and full remote control where clicking into viewport allows taking over mouse and keyboard (press Escape to release).

playwright-cli headed mode

The CLI runs headless by default. To see the browser, use: playwright-cli open https://example.com --headed

playwright-cli browser selection

To use a specific browser: playwright-cli open --browser=chrome for Chrome, playwright-cli open --browser=firefox for Firefox, playwright-cli open --browser=webkit for WebKit, playwright-cli open --browser=msedge for Microsoft Edge.

playwright-cli configuration file

For advanced settings, use a JSON config file with: playwright-cli --config path/to/config.json open example.com. The CLI also automatically loads .playwright/cli.config.json if present. The config file supports browser options, context options, network rules, timeouts, and more.

playwright-cli browser extension connection

To connect to existing browser tabs instead of launching new browser, use: playwright-cli attach --extension. This requires the Playwright Extension to be installed.

Give your agent this brain