Skip to main content

Command Reference

Every command below is always available — unlike MCP, the CLI has no capability gating. The groups match the ones printed by playwright-cli --help; use playwright-cli --help <command> for the exact arguments and options of a single command.

Arguments in <angle brackets> are required, arguments in [square brackets] are optional.

Core

CommandDescription
open [url]Open the browser, optionally navigating to a URL
attach [name]Attach to a running Playwright browser
closeClose the browser
detachDetach from an attached browser, leaving it running
goto <url>Navigate to a URL
type <text>Type text into the focused editable element
click <target> [button]Click an element
dblclick <target> [button]Double-click an element
fill <target> <text>Fill text into an editable element
drag <startTarget> <endTarget>Drag and drop between two elements
drop <target>Drop files or data onto an element from outside the page
hover <target>Hover over an element
select <target> <val>Select an option in a dropdown
upload <files...>Upload one or more files
check <target> / uncheck <target>Check or uncheck a checkbox or radio button
snapshot [target]Capture a page snapshot to obtain element refs
find [text]Search the page snapshot, returning matches with context
eval <func> [target]Evaluate JavaScript on the page or an element
dialog-accept [prompt] / dialog-dismissHandle a dialog
resize <w> <h>Resize the browser window
delete-dataDelete the session's user data

See Interaction, Navigation and Dialogs.

CommandDescription
go-backGo back to the previous page
go-forwardGo forward to the next page
reloadReload the current page

Keyboard

CommandDescription
press <key>Press a key, e.g. Enter or ArrowLeft
keydown <key> / keyup <key>Press a key down or release it

Mouse

Coordinate-based interaction using pixel positions from screenshots. Useful for canvas apps, maps, and custom widgets without accessible elements.

CommandDescription
mousemove <x> <y>Move the mouse to coordinates
mousedown [button] / mouseup [button]Press or release a mouse button
mousewheel <dx> <dy>Scroll with the mouse wheel

See Vision Mode.

Save as

CommandDescription
screenshot [target]Screenshot of the page or an element
pdfSave the page as PDF

See Screenshots & PDF.

Tabs

CommandDescription
tab-listList all tabs
tab-new [url]Create a new tab
tab-close [index]Close a tab (the current one if no index)
tab-select <index>Switch to a tab

See Tabs.

Storage

CommandDescription
state-save [filename] / state-load <filename>Save or restore browser storage state
cookie-list, cookie-get, cookie-set, cookie-delete, cookie-clearManage cookies
localstorage-list/get/set/delete/clearManage localStorage
sessionstorage-list/get/set/delete/clearManage sessionStorage

See Storage & Authentication.

Network

CommandDescription
requestsList network requests, numbered for use with request
request <index>Full details of a single request
request-headers <index> / request-body <index>One part of the request
response-headers <index> / response-body <index>One part of the response
route <pattern>Mock requests matching a URL pattern
route-listList active routes
unroute [pattern]Remove matching routes, or all of them
network-state-set <state>Set the browser online or offline

See Network & Mocking.

DevTools

CommandDescription
console [min-level]List console messages
run-code [code]Run a Playwright code snippet
recording-start / recording-stopRecord user actions and print them as Playwright code
tracing-start / tracing-stopRecord an execution trace
video-start [filename] / video-stopRecord a video
video-chapter <title>Add a chapter marker to the video
video-show-actions / video-hide-actionsAnnotate actions in the recorded video
showOpen the Playwright dashboard
pause-at <location>, resume, step-overControl a paused test
generate-locator <target>Generate a Playwright locator for an element
highlight [target]Show or hide a highlight overlay on the page

See Console & Eval, Codegen & Highlighting, Tracing, Video Recording and Test Debugging.

Install

CommandDescription
installInitialize the workspace, optionally installing skills
install-browser [browser]Install a browser

See Installation.

Browser sessions

CommandDescription
listList browser sessions
close-allClose all browser sessions
kill-allForcefully kill stale or zombie browser processes

See Sessions & Dashboard.

Global options

These apply to every command and can be placed anywhere on the command line.

OptionDescription
-s=<name>, --session=<name>Run against a named browser session
--rawPrint only the result value, without page status, generated code, or snapshot
--jsonWrap the whole reply as JSON
--help [command]Print help
--versionPrint the version
# pipe a value straight into another tool
playwright-cli --raw eval "JSON.stringify(performance.timing)" | jq '.loadEventEnd - .navigationStart'
playwright-cli --raw snapshot > before.yml

# structured output for scripting
playwright-cli list --json