| name | playwright-cli |
| description | Automate browser interactions, test web pages and work with Playwright tests. |
| allowed-tools | ["Bash(playwright-cli:*)","Bash(npx:*)","Bash(npm:*)"] |
Browser Automation with playwright-cli
Use playwright-cli to inspect a live page and discover the real flow, stable
selectors, and cookie/consent steps before authoring a ScreenCI .screenci.ts
script. It drives a real browser from the CLI: navigate, snapshot, click, type.
When Inspecting Pages For ScreenCI
- After the first navigation and snapshot, check whether a cookie consent or
cookie policy banner appeared.
- Identify the exact accept action the video script should use inside its initial
hide() block, preferably a stable locator such as
getByRole('button', { name: /accept|accept all|allow all|agree|ok/i }).
- If multiple consent actions exist, prefer the clear accept/allow action over a
dismiss-only or settings action.
- Report that cookie-consent click as part of the hidden initial setup, not as a
visible demo step.
Quick start
playwright-cli open
playwright-cli goto https://playwright.dev
playwright-cli click e15
playwright-cli type "page.click"
playwright-cli press Enter
playwright-cli close
Core commands
playwright-cli open
playwright-cli open https://example.com/
playwright-cli goto https://playwright.dev
playwright-cli type "search query"
playwright-cli click e3
playwright-cli dblclick e7
playwright-cli fill e5 "user@example.com" --submit
playwright-cli hover e4
playwright-cli select e9 "option-value"
playwright-cli check e12
playwright-cli uncheck e12
playwright-cli snapshot
playwright-cli eval "document.title"
playwright-cli eval "el => el.textContent" e5
playwright-cli eval "el => el.getAttribute('data-testid')" e5
playwright-cli close
Navigation
playwright-cli go-back
playwright-cli go-forward
playwright-cli reload
playwright-cli press Enter
playwright-cli press ArrowDown
Snapshots
After each command, playwright-cli provides a snapshot of the current browser state.
> playwright-cli goto https://example.com
- Page URL: https://example.com/
- Page Title: Example Domain
[Snapshot](.playwright-cli/page-2026-02-14T19-22-42-679Z.yml)
You can also take a snapshot on demand. Options can be combined.
playwright-cli snapshot
playwright-cli snapshot "#main"
playwright-cli snapshot --depth=4
playwright-cli snapshot e34
The global --raw option strips page status and generated code, returning only
the result value. Use it to pipe output into other tools.
playwright-cli --raw snapshot > before.yml
playwright-cli click e5
playwright-cli --raw snapshot > after.yml
diff before.yml after.yml
Targeting elements
By default, use refs from the snapshot to interact with page elements.
playwright-cli snapshot
playwright-cli click e15
You can also use css selectors or Playwright locators.
playwright-cli click "#main > button.submit"
playwright-cli click "getByRole('button', { name: 'Submit' })"
playwright-cli click "getByTestId('submit-button')"
Browser Sessions
playwright-cli -s=mysession open example.com
playwright-cli -s=mysession click e6
playwright-cli -s=mysession close
playwright-cli list
playwright-cli close-all
Installation
If global playwright-cli is not available, try a local version:
npx --no-install playwright-cli --version
Otherwise install it globally:
npm install -g @playwright/cli@latest
Example: Form submission
playwright-cli open https://example.com/form
playwright-cli snapshot
playwright-cli fill e1 "user@example.com"
playwright-cli fill e2 "password123"
playwright-cli click e3
playwright-cli snapshot
playwright-cli close