CLI Reference
playwright-cli commands
Search by command, option, or keyword, or jump straight to a group.
Quick group filters
Installation & setup
3 commandsInstall the CLI, add skills, and verify the command is available.
Install the CLI
Install the latest global playwright-cli binary.
npm install -g @playwright/cli@latestInstall skills
Add the local skill files your coding agent can read.
playwright-cli install --skillsVerify the install
Check that the CLI is available and list the current commands.
playwright-cli --helpCore
24 commandsOpen pages, interact with elements, capture snapshots, and evaluate code.
Open a page
Open the browser and optionally navigate to a URL. Add options like `--headed` when needed.
playwright-cli open [url]Option example
Open with a visible browser window while you inspect the flow.
playwright-cli open https://demo.playwright.dev/todomvc/ --headedGo to a URL
Navigate the current page to a new address.
playwright-cli goto <url>Close the page
Close the active page.
playwright-cli closeType text
Type into the currently focused editable element.
playwright-cli type <text>Click an element
Perform a click on a page element.
playwright-cli click <ref> [button]Double click
Perform a double click on a page element.
playwright-cli dblclick <ref> [button]Fill text
Replace the element value with text.
playwright-cli fill <ref> <text>Fill and submit
Fill text and press Enter in one step.
playwright-cli fill <ref> <text> --submitDrag and drop
Drag from one element ref to another.
playwright-cli drag <startRef> <endRef>Drop a file
Drop a file from outside the page onto an element.
playwright-cli drop <ref> --path=<file>Drop data
Drop key-value data onto an element.
playwright-cli drop <ref> --data="k=v"Hover
Hover over an element on the page.
playwright-cli hover <ref>Select an option
Choose a value in a dropdown.
playwright-cli select <ref> <val>Upload files
Upload one or more files.
playwright-cli upload <file>Check
Check a checkbox or radio button.
playwright-cli check <ref>Uncheck
Uncheck a checkbox or radio button.
playwright-cli uncheck <ref>Snapshot the page
Capture a page snapshot to get element refs.
playwright-cli snapshotSave a named snapshot
Write a snapshot to a specific file.
playwright-cli snapshot --filename=fSnapshot an element
Capture a snapshot for a single element.
playwright-cli snapshot <ref>Limit snapshot depth
Trim snapshot depth for faster output.
playwright-cli snapshot --depth=NEvaluate JavaScript
Run a JavaScript expression on the page or element.
playwright-cli eval <func> [ref]Accept a dialog
Accept the current dialog, optionally with prompt text.
playwright-cli dialog-accept [prompt]Dismiss a dialog
Dismiss the current dialog.
playwright-cli dialog-dismissResize the window
Resize the browser window.
playwright-cli resize <w> <h>Navigation
3 commandsMove through browser history and refresh the current page.
Go back
Go to the previous page in history.
playwright-cli go-backGo forward
Go to the next page in history.
playwright-cli go-forwardReload
Reload the current page.
playwright-cli reloadKeyboard
3 commandsSend keyboard input and hold or release specific keys.
Press a key
Press a single key such as Enter or ArrowLeft.
playwright-cli press <key>Key down
Hold a key down.
playwright-cli keydown <key>Key up
Release a key.
playwright-cli keyup <key>Mouse
4 commandsDrive the mouse directly with coordinates, buttons, and wheel input.
Move the mouse
Move the cursor to a specific position.
playwright-cli mousemove <x> <y>Mouse down
Press a mouse button down.
playwright-cli mousedown [button]Mouse up
Release a mouse button.
playwright-cli mouseup [button]Mouse wheel
Scroll the mouse wheel.
playwright-cli mousewheel <dx> <dy>Save as
4 commandsCapture screenshots and PDFs for review or sharing.
Take a screenshot
Capture the current page or a single element.
playwright-cli screenshot [ref]Save a named screenshot
Save a screenshot with a specific filename.
playwright-cli screenshot --filename=fSave as PDF
Export the current page as a PDF.
playwright-cli pdfSave a named PDF
Export a PDF with a specific filename.
playwright-cli pdf --filename=page.pdfTabs
4 commandsCreate, list, switch, and close browser tabs.
List tabs
Show all open tabs.
playwright-cli tab-listOpen a new tab
Create a new tab and optionally navigate to a URL.
playwright-cli tab-new [url]Close a tab
Close the current tab or a tab by index.
playwright-cli tab-close [index]Select a tab
Switch to a tab by index.
playwright-cli tab-select <index>Storage
17 commandsWork with storage state, cookies, localStorage, and sessionStorage.
Save storage state
Save the current storage state to a file.
playwright-cli state-save [filename]Load storage state
Restore storage state from a file.
playwright-cli state-load <filename>List cookies
List cookies, optionally for a specific domain.
playwright-cli cookie-list [--domain]Get a cookie
Read a cookie by name.
playwright-cli cookie-get <name>Set a cookie
Create or update a cookie value.
playwright-cli cookie-set <name> <val>Delete a cookie
Delete a cookie by name.
playwright-cli cookie-delete <name>Clear cookies
Remove all cookies.
playwright-cli cookie-clearList localStorage
List localStorage entries.
playwright-cli localstorage-listGet localStorage
Read a localStorage value by key.
playwright-cli localstorage-get <key>Set localStorage
Write a localStorage value.
playwright-cli localstorage-set <k> <v>Delete localStorage
Delete a localStorage entry.
playwright-cli localstorage-delete <k>Clear localStorage
Remove all localStorage entries.
playwright-cli localstorage-clearList sessionStorage
List sessionStorage entries.
playwright-cli sessionstorage-listGet sessionStorage
Read a sessionStorage value by key.
playwright-cli sessionstorage-get <k>Set sessionStorage
Write a sessionStorage value.
playwright-cli sessionstorage-set <k> <v>Delete sessionStorage
Delete a sessionStorage entry.
playwright-cli sessionstorage-delete <k>Clear sessionStorage
Remove all sessionStorage entries.
playwright-cli sessionstorage-clearNetwork
3 commandsMock, inspect, and remove network routes.
Add a route
Mock matching network requests.
playwright-cli route <pattern> [opts]List routes
Show active network routes.
playwright-cli route-listRemove routes
Remove one route or all matching routes.
playwright-cli unroute [pattern]Monitoring
2 commandsOpen the visual dashboard for live review and UI feedback.
Open the dashboard
Launch the visual dashboard for the current browser session.
playwright-cli showOpen annotated review mode
Launch the dashboard for design feedback and UI review.
playwright-cli show --annotateDevTools
15 commandsInspect console output, requests, traces, videos, locators, and highlights.
List console messages
Show console messages, optionally filtered by minimum level.
playwright-cli console [min-level]List requests
Show all requests since the page loaded.
playwright-cli requestsInspect one request
Show details for a specific request.
playwright-cli request <index>Run inline code
Run a Playwright code snippet.
playwright-cli run-code <code>Run code from a file
Run a Playwright code file.
playwright-cli run-code --filename=fStart tracing
Begin trace recording.
playwright-cli tracing-startStop tracing
Stop trace recording.
playwright-cli tracing-stopStart video
Begin video recording for the session.
playwright-cli video-start [filename]Add video chapter
Insert a chapter marker into the recording.
playwright-cli video-chapter <title>Stop video
Stop video recording.
playwright-cli video-stopGenerate a locator
Generate a Playwright locator from an element ref.
playwright-cli generate-locator <ref>Highlight an element
Show a persistent highlight overlay.
playwright-cli highlight <ref>Highlight with custom style
Apply a custom CSS highlight style.
playwright-cli highlight <ref> --style=Hide one highlight
Remove the highlight from a specific element.
playwright-cli highlight <ref> --hideHide all highlights
Remove every highlight from the page.
playwright-cli highlight --hideOpen parameters
10 commandsLaunch with a specific browser, profile, config, or attached session.
Open with a browser
Use a specific browser channel.
playwright-cli open --browser=chromeAttach with extension
Connect through the Playwright browser extension.
playwright-cli attach --extension=chromeAttach by channel
Attach to a running Chrome or Edge instance by channel.
playwright-cli attach --cdp=chromeAttach by endpoint
Attach through a CDP endpoint URL.
playwright-cli attach --cdp=<url>Detach
Detach and leave the external browser running.
playwright-cli detachUse a persistent profile
Start with a persistent browser profile.
playwright-cli open --persistentUse a custom profile path
Start with a specific profile directory.
playwright-cli open --profile=<path>Use a config file
Start with an explicit config file.
playwright-cli open --config=file.jsonClose the browser
Close the browser process.
playwright-cli closeDelete stored data
Delete user data for the default session.
playwright-cli delete-dataSnapshots
6 commandsCapture on-demand snapshots with filename, depth, selector, and box options.
Default snapshot
Save a timestamped snapshot file.
playwright-cli snapshotNamed snapshot
Save a snapshot with a stable filename.
playwright-cli snapshot --filename=after-click.yamlSnapshot a selector
Capture just one element instead of the full page.
playwright-cli snapshot "#main"Limit snapshot depth
Create a shallower snapshot for faster workflows.
playwright-cli snapshot --depth=4Snapshot by ref
Capture a specific element using its ref.
playwright-cli snapshot e34Include element boxes
Include bounding boxes for each element.
playwright-cli snapshot --boxesTargeting elements
5 commandsInteract with refs, CSS selectors, role locators, and test IDs.
Get refs first
Capture a snapshot so you can target elements by ref.
playwright-cli snapshotClick by ref
Interact with an element using the snapshot ref.
playwright-cli click e15Click by CSS selector
Target an element with a CSS selector.
playwright-cli click "#main > button.submit"Click by role locator
Target an element with a Playwright role locator.
playwright-cli click "getByRole('button', { name: 'Submit' })"Click by test ID
Target an element with a Playwright test ID.
playwright-cli click "getByTestId('submit-button')"Sessions
7 commandsRun commands in named sessions and manage all open browser sessions.
Run in a named session
Run any command inside a named session.
playwright-cli -s=name <cmd>Close one named session
Stop a named browser session.
playwright-cli -s=name closeDelete one named session
Delete user data for a named browser.
playwright-cli -s=name delete-dataUse the session env var
Set the session name through the shell environment.
PLAYWRIGHT_CLI_SESSION=bug-bash playwright-cli open https://example.comList sessions
Show all active sessions.
playwright-cli listClose all sessions
Close every open browser.
playwright-cli close-allKill all sessions
Force kill every browser process.
playwright-cli kill-allLocal installation
2 commandsUse the local CLI with npx when the global command is not available.
Check the local CLI
Verify that a local install is available through npx.
npx --no-install playwright-cli --versionFallback global install
Install the global CLI if the local version is missing.
npm install -g @playwright/cli@latestConfiguration
1 commandRun commands with an explicit JSON config file.
Use a config file
Pass a config file path on the command line.
playwright-cli --config path/to/config.json open example.com