Skip to main content

Sessions & Dashboard

The CLI keeps the browser profile in memory by default — cookies and storage state are preserved between CLI calls within a session but lost when the browser closes.

Named sessions

Run multiple isolated browser instances:

playwright-cli open https://playwright.dev
playwright-cli -s=example open https://example.com --persistent
playwright-cli list
### Browsers
- default:
- status: open
- browser-type: chrome
- user-data-dir: <in-memory>
- headed: false
- example:
- status: open
- browser-type: chrome
- user-data-dir: /Users/me/Library/Caches/ms-playwright/daemon/8f2c.../ud-example-chrome
- headed: false

Each session has its own browser instance, cookies, localStorage, IndexedDB, cache, navigation history, open tabs, and console log.

playwright-cli list --all widens the listing to every workspace, and adds the Playwright browser servers and the local Chrome/Edge profiles that are available to attach to.

Environment variable

PLAYWRIGHT_CLI_SESSION=todo-app claude .

All playwright-cli commands in that agent session use the todo-app browser instance.

Profile persistence

In-memory (default)

Cookies and storage persist between commands within a session but are lost when the browser closes:

playwright-cli open https://example.com

Persistent to disk

Profile is saved to disk and survives browser restarts. This is equivalent to the default persistent mode in Playwright MCP.

playwright-cli open https://example.com --persistent

The profile directory is derived from the workspace and the session name — ud-<session>-<browser> under a per-workspace directory:

PlatformDefault location
macOS~/Library/Caches/ms-playwright/daemon/<workspace-hash>/
Linux$XDG_CACHE_HOME/ms-playwright/daemon/<workspace-hash>/ (defaults to ~/.cache)
Windows%LOCALAPPDATA%\ms-playwright\daemon\<workspace-hash>\

Custom directory

playwright-cli open https://example.com --profile=./my-profile

Session management

playwright-cli list # list sessions in this workspace
playwright-cli list --all # list sessions across all workspaces
playwright-cli -s=name close # close a specific session
playwright-cli -s=name detach # detach without closing an attached browser
playwright-cli close-all # close all browsers
playwright-cli kill-all # force kill (for unresponsive browsers)
playwright-cli -s=name delete-data # delete stored profile data

close stops the browser the CLI launched. For sessions created with attach, use detach — it tears down the session and leaves the external browser running. See Attach.

Dashboard

Open a visual dashboard to observe and control all running sessions:

playwright-cli show

The dashboard provides:

ViewDescription
Session gridAll active sessions with live screencast, name, URL, and title. Click to zoom in.
Session detailLive viewport with tab bar, navigation controls, and full remote mouse/keyboard input. Press Escape to release.

Use cases:

  • Watch coding agents automate browsers in the background
  • Take over when an agent gets stuck on a CAPTCHA or 2FA
  • Close stale sessions or delete data from the UI

Options

playwright-cli show # launch the dashboard in the background
playwright-cli -s=name show # launch it and reveal a specific session
playwright-cli show --port=0 # run as a blocking HTTP server on a random port
playwright-cli show --port=8080 --host=0.0.0.0
playwright-cli show --kill # stop the dashboard daemon

Annotation mode

show --annotate turns the dashboard into a feedback tool: the user draws boxes on the live page and types comments, and the command returns the annotated screenshot, the snapshot of the marked region, and the notes. It blocks until the user is done, which makes it the way to ask for a UI review or design feedback mid-automation.

playwright-cli open https://example.com
playwright-cli show --annotate

Saving and restoring state

Save authenticated state for reuse across sessions:

# Login, then save state
playwright-cli state-save auth-state.json

# Later: restore state in a new session
playwright-cli state-load auth-state.json

Workflow: isolated testing

# Admin session
playwright-cli -s=admin open https://app.example.com --persistent
playwright-cli -s=admin state-load admin-auth.json
playwright-cli -s=admin goto /admin/settings

# User session
playwright-cli -s=user open https://app.example.com --persistent
playwright-cli -s=user state-load user-auth.json
playwright-cli -s=user goto /dashboard

# Monitor both
playwright-cli show