docs/playwright-cli.md
[Skip to content](https://github.com/microsoft/playwright-cli#start-of-content)
You signed in with another tab or window. [Reload](https://github.com/microsoft/playwright-cli) to refresh your session.You signed out in another tab or window. [Reload](https://github.com/microsoft/playwright-cli) to refresh your session.You switched accounts on another tab or window. [Reload](https://github.com/microsoft/playwright-cli) to refresh your session.Dismiss alert
{{ message }}
[microsoft](https://github.com/microsoft)/ **[playwright-cli](https://github.com/microsoft/playwright-cli)** Public
- [Notifications](https://github.com/login?return_to=%2Fmicrosoft%2Fplaywright-cli) You must be signed in to change notification settings
- [Fork\\
108](https://github.com/login?return_to=%2Fmicrosoft%2Fplaywright-cli)
- [Star\\
2.7k](https://github.com/login?return_to=%2Fmicrosoft%2Fplaywright-cli)
CLI for common Playwright actions. Record and generate Playwright code, inspect selectors and take screenshots.
[playwright.dev](https://playwright.dev/ "https://playwright.dev")
### License
[Apache-2.0 license](https://github.com/microsoft/playwright-cli/blob/main/LICENSE)
[2.7k\\
stars](https://github.com/microsoft/playwright-cli/stargazers) [108\\
forks](https://github.com/microsoft/playwright-cli/forks) [Branches](https://github.com/microsoft/playwright-cli/branches) [Tags](https://github.com/microsoft/playwright-cli/tags) [Activity](https://github.com/microsoft/playwright-cli/activity)
[Star](https://github.com/login?return_to=%2Fmicrosoft%2Fplaywright-cli)
[Notifications](https://github.com/login?return_to=%2Fmicrosoft%2Fplaywright-cli) You must be signed in to change notification settings
# microsoft/playwright-cli
main
[**10** Branches](https://github.com/microsoft/playwright-cli/branches) [**16** Tags](https://github.com/microsoft/playwright-cli/tags)
[Go to Branches page](https://github.com/microsoft/playwright-cli/branches)[Go to Tags page](https://github.com/microsoft/playwright-cli/tags)
Go to file
Code
Open more actions menu
## Folders and files
| Name | Name | Last commit message | Last commit date |
| --- | --- | --- | --- |
| ## Latest commit<br>[](https://github.com/pavelfeldman)[pavelfeldman](https://github.com/microsoft/playwright-cli/commits?author=pavelfeldman)<br>[chore: mark v0.1.0 (](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9) [#239](https://github.com/microsoft/playwright-cli/pull/239) [)](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9)<br>success<br>2 days agoFeb 6, 2026<br>[7ff4d62](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9) · 2 days agoFeb 6, 2026<br>## History<br>[43 Commits](https://github.com/microsoft/playwright-cli/commits/main/) <br>Open commit details<br>[View commit history for this file.](https://github.com/microsoft/playwright-cli/commits/main/) 43 Commits |
| [.claude-plugin](https://github.com/microsoft/playwright-cli/tree/main/.claude-plugin ".claude-plugin") | [.claude-plugin](https://github.com/microsoft/playwright-cli/tree/main/.claude-plugin ".claude-plugin") | [init](https://github.com/microsoft/playwright-cli/commit/6f65c80c87e2b3b2c3712d6c2a730530c5a50121 "init") | 2 weeks agoJan 23, 2026 |
| [.claude/skills/roll](https://github.com/microsoft/playwright-cli/tree/main/.claude/skills/roll "This path skips through empty directories") | [.claude/skills/roll](https://github.com/microsoft/playwright-cli/tree/main/.claude/skills/roll "This path skips through empty directories") | [devops: move claude roll skill](https://github.com/microsoft/playwright-cli/commit/cc0bf3ab6d263a5cfc72646280a1d55b5d70db14 "devops: move claude roll skill") | 2 days agoFeb 6, 2026 |
| [.github/workflows](https://github.com/microsoft/playwright-cli/tree/main/.github/workflows "This path skips through empty directories") | [.github/workflows](https://github.com/microsoft/playwright-cli/tree/main/.github/workflows "This path skips through empty directories") | [chore: mark v0.1.0 (](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") [#239](https://github.com/microsoft/playwright-cli/pull/239) [)](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") | 2 days agoFeb 6, 2026 |
| [scripts](https://github.com/microsoft/playwright-cli/tree/main/scripts "scripts") | [scripts](https://github.com/microsoft/playwright-cli/tree/main/scripts "scripts") | [chore: update skill files](https://github.com/microsoft/playwright-cli/commit/4fafcccadd265f959b41ee8bc87eff7cc607e8e7 "chore: update skill files") | 2 days agoFeb 6, 2026 |
| [skills/playwright-cli](https://github.com/microsoft/playwright-cli/tree/main/skills/playwright-cli "This path skips through empty directories") | [skills/playwright-cli](https://github.com/microsoft/playwright-cli/tree/main/skills/playwright-cli "This path skips through empty directories") | [chore: update skill files](https://github.com/microsoft/playwright-cli/commit/4fafcccadd265f959b41ee8bc87eff7cc607e8e7 "chore: update skill files") | 2 days agoFeb 6, 2026 |
| [tests](https://github.com/microsoft/playwright-cli/tree/main/tests "tests") | [tests](https://github.com/microsoft/playwright-cli/tree/main/tests "tests") | [devops: move npm source from playwright-mcp repo (](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") [#237](https://github.com/microsoft/playwright-cli/pull/237) [)](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") | 2 days agoFeb 6, 2026 |
| [.gitignore](https://github.com/microsoft/playwright-cli/blob/main/.gitignore ".gitignore") | [.gitignore](https://github.com/microsoft/playwright-cli/blob/main/.gitignore ".gitignore") | [devops: move claude roll skill](https://github.com/microsoft/playwright-cli/commit/cc0bf3ab6d263a5cfc72646280a1d55b5d70db14 "devops: move claude roll skill") | 2 days agoFeb 6, 2026 |
| [.npmignore](https://github.com/microsoft/playwright-cli/blob/main/.npmignore ".npmignore") | [.npmignore](https://github.com/microsoft/playwright-cli/blob/main/.npmignore ".npmignore") | [devops: move npm source from playwright-mcp repo (](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") [#237](https://github.com/microsoft/playwright-cli/pull/237) [)](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") | 2 days agoFeb 6, 2026 |
| [CONTRIBUTING.md](https://github.com/microsoft/playwright-cli/blob/main/CONTRIBUTING.md "CONTRIBUTING.md") | [CONTRIBUTING.md](https://github.com/microsoft/playwright-cli/blob/main/CONTRIBUTING.md "CONTRIBUTING.md") | [Update contributing guidelines for clarity and structure](https://github.com/microsoft/playwright-cli/commit/220e8a5b3e56732d575ed54b4e8ed5e3df98939b "Update contributing guidelines for clarity and structure") | 2 weeks agoJan 24, 2026 |
| [LICENSE](https://github.com/microsoft/playwright-cli/blob/main/LICENSE "LICENSE") | [LICENSE](https://github.com/microsoft/playwright-cli/blob/main/LICENSE "LICENSE") | [chore: added license file](https://github.com/microsoft/playwright-cli/commit/2db417fa2490e9670005016442dee1e35ca5de0e "chore: added license file") | 2 weeks agoJan 24, 2026 |
| [README.md](https://github.com/microsoft/playwright-cli/blob/main/README.md "README.md") | [README.md](https://github.com/microsoft/playwright-cli/blob/main/README.md "README.md") | [chore: update readme for 0.0.66](https://github.com/microsoft/playwright-cli/commit/3ed6f7558a7bcb45238be4c5cbc6c3dafba676f2 "chore: update readme for 0.0.66") | 2 days agoFeb 6, 2026 |
| [SECURITY.md](https://github.com/microsoft/playwright-cli/blob/main/SECURITY.md "SECURITY.md") | [SECURITY.md](https://github.com/microsoft/playwright-cli/blob/main/SECURITY.md "SECURITY.md") | [chore: added security file](https://github.com/microsoft/playwright-cli/commit/c61b4fdb9b4632afddb1dec5a76bc90182ca69c0 "chore: added security file") | 2 weeks agoJan 24, 2026 |
| [package-lock.json](https://github.com/microsoft/playwright-cli/blob/main/package-lock.json "package-lock.json") | [package-lock.json](https://github.com/microsoft/playwright-cli/blob/main/package-lock.json "package-lock.json") | [chore: mark v0.1.0 (](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") [#239](https://github.com/microsoft/playwright-cli/pull/239) [)](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") | 2 days agoFeb 6, 2026 |
| [package.json](https://github.com/microsoft/playwright-cli/blob/main/package.json "package.json") | [package.json](https://github.com/microsoft/playwright-cli/blob/main/package.json "package.json") | [chore: mark v0.1.0 (](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") [#239](https://github.com/microsoft/playwright-cli/pull/239) [)](https://github.com/microsoft/playwright-cli/commit/7ff4d6258fe9d1123a560c676bd0dad70a022aa9 "chore: mark v0.1.0 (#239)") | 2 days agoFeb 6, 2026 |
| [playwright-cli.js](https://github.com/microsoft/playwright-cli/blob/main/playwright-cli.js "playwright-cli.js") | [playwright-cli.js](https://github.com/microsoft/playwright-cli/blob/main/playwright-cli.js "playwright-cli.js") | [devops: move npm source from playwright-mcp repo (](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") [#237](https://github.com/microsoft/playwright-cli/pull/237) [)](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") | 2 days agoFeb 6, 2026 |
| [playwright.config.ts](https://github.com/microsoft/playwright-cli/blob/main/playwright.config.ts "playwright.config.ts") | [playwright.config.ts](https://github.com/microsoft/playwright-cli/blob/main/playwright.config.ts "playwright.config.ts") | [devops: move npm source from playwright-mcp repo (](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") [#237](https://github.com/microsoft/playwright-cli/pull/237) [)](https://github.com/microsoft/playwright-cli/commit/e53f1085f730811b803fc3cbf61d754d9a42cb9e "devops: move npm source from playwright-mcp repo (#237)") | 2 days agoFeb 6, 2026 |
| View all files |
## Repository files navigation
# playwright-cli
[Permalink: playwright-cli](https://github.com/microsoft/playwright-cli#playwright-cli)
Playwright CLI with SKILLS
### Playwright CLI vs Playwright MCP
[Permalink: Playwright CLI vs Playwright MCP](https://github.com/microsoft/playwright-cli#playwright-cli-vs-playwright-mcp)
This package provides CLI interface into Playwright. If you are using **coding agents**, that is the best fit.
- **CLI**: Modern **coding agents** increasingly favor CLI–based workflows exposed as SKILLs over MCP because CLI invocations are more token-efficient: they avoid loading large tool schemas and verbose accessibility trees into the model context, allowing agents to act through concise, purpose-built commands. This makes CLI + SKILLs better suited for high-throughput coding agents that must balance browser automation with large codebases, tests, and reasoning within limited context windows.
- **MCP**: MCP remains relevant for specialized agentic loops that benefit from persistent state, rich introspection, and iterative reasoning over page structure, such as exploratory automation, self-healing tests, or long-running autonomous workflows where maintaining continuous browser context outweighs token cost concerns. Learn more about [Playwright MCP](https://github.com/microsoft/playwright-mcp).
### Key Features
[Permalink: Key Features](https://github.com/microsoft/playwright-cli#key-features)
- **Token-efficient**. Does not force page data into LLM.
### Requirements
[Permalink: Requirements](https://github.com/microsoft/playwright-cli#requirements)
- Node.js 18 or newer
- Claude Code, GitHub Copilot, or any other coding agent.
## Getting Started
[Permalink: Getting Started](https://github.com/microsoft/playwright-cli#getting-started)
## Installation
[Permalink: Installation](https://github.com/microsoft/playwright-cli#installation)
```
npm install -g @playwright/cli@latest
playwright-cli --help
```
### Installing skills
[Permalink: Installing skills](https://github.com/microsoft/playwright-cli#installing-skills)
Claude Code, GitHub Copilot and others will use the locally installed skills.
```
playwright-cli install --skills
```
### Skills-less operation
[Permalink: Skills-less operation](https://github.com/microsoft/playwright-cli#skills-less-operation)
Point your agent at the CLI and let it cook. It'll read the skill off `playwright-cli --help` on its own:
```
Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
Check playwright-cli --help for available commands.
```
## Demo
[Permalink: Demo](https://github.com/microsoft/playwright-cli#demo)
```
> Use playwright skills to test https://demo.playwright.dev/todomvc/.
Take screenshots for all successful and failing scenarios.
```
Your agent will be running commands, but it does not mean you can't play with it manually:
```
playwright-cli open https://demo.playwright.dev/todomvc/ --headed
playwright-cli type "Buy groceries"
playwright-cli press Enter
playwright-cli type "Water flowers"
playwright-cli press Enter
playwright-cli check e21
playwright-cli check e35
playwright-cli screenshot
```
## Headed operation
[Permalink: Headed operation](https://github.com/microsoft/playwright-cli#headed-operation)
Playwright CLI is headless by default. If you'd like to see the browser, pass `--headed` to `open`:
```
playwright-cli open https://playwright.dev --headed
```
## Sessions
[Permalink: Sessions](https://github.com/microsoft/playwright-cli#sessions)
Playwright CLI will use a dedicated persistent profile by default. It means that
your cookies and other storage state will be preserved between the calls. You can use different
instances of the browser for different projects with sessions.
Following will result in two browsers with separate profiles being available. Pass `-s=` to
the invocation to talk to a specific browser.
```
playwright-cli open https://playwright.dev
playwright-cli -s=example open https://example.com
playwright-cli list
```
You can run your coding agent with the `PLAYWRIGHT_CLI_SESSION` environment variable:
```
PLAYWRIGHT_CLI_SESSION=todo-app claude .
```
Or instruct it to prepend `-s=` to the calls.
Manage your sessions as follows:
```
playwright-cli list # list all sessions
playwright-cli close-all # close all browsers
playwright-cli kill-all # forcefully kill all browser processes
```
## Commands
[Permalink: Commands](https://github.com/microsoft/playwright-cli#commands)
### Core
[Permalink: Core](https://github.com/microsoft/playwright-cli#core)
```
playwright-cli open [url] # open browser, optionally navigate to url
playwright-cli goto <url> # navigate to a url
playwright-cli close # close the page
playwright-cli type <text> # type text into editable element
playwright-cli click <ref> [button] # perform click on a web page
playwright-cli dblclick <ref> [button] # perform double click on a web page
playwright-cli fill <ref> <text> # fill text into editable element
playwright-cli drag <startRef> <endRef> # perform drag and drop between two elements
playwright-cli hover <ref> # hover over element on page
playwright-cli select <ref> <val> # select an option in a dropdown
playwright-cli upload <file> # upload one or multiple files
playwright-cli check <ref> # check a checkbox or radio button
playwright-cli uncheck <ref> # uncheck a checkbox or radio button
playwright-cli snapshot # capture page snapshot to obtain element ref
playwright-cli snapshot --filename=f # save snapshot to specific file
playwright-cli eval <func> [ref] # evaluate javascript expression on page or element
playwright-cli dialog-accept [prompt] # accept a dialog
playwright-cli dialog-dismiss # dismiss a dialog
playwright-cli resize <w> <h> # resize the browser window
```
### Navigation
[Permalink: Navigation](https://github.com/microsoft/playwright-cli#navigation)
```
playwright-cli go-back # go back to the previous page
playwright-cli go-forward # go forward to the next page
playwright-cli reload # reload the current page
```
### Keyboard
[Permalink: Keyboard](https://github.com/microsoft/playwright-cli#keyboard)
```
playwright-cli press <key> # press a key on the keyboard, `a`, `arrowleft`
playwright-cli keydown <key> # press a key down on the keyboard
playwright-cli keyup <key> # press a key up on the keyboard
```
### Mouse
[Permalink: Mouse](https://github.com/microsoft/playwright-cli#mouse)
```
playwright-cli mousemove <x> <y> # move mouse to a given position
playwright-cli mousedown [button] # press mouse down
playwright-cli mouseup [button] # press mouse up
playwright-cli mousewheel <dx> <dy> # scroll mouse wheel
```
### Save as
[Permalink: Save as](https://github.com/microsoft/playwright-cli#save-as)
```
playwright-cli screenshot [ref] # screenshot of the current page or element
playwright-cli screenshot --filename=f # save screenshot with specific filename
playwright-cli pdf # save page as pdf
playwright-cli pdf --filename=page.pdf # save pdf with specific filename
```
### Tabs
[Permalink: Tabs](https://github.com/microsoft/playwright-cli#tabs)
```
playwright-cli tab-list # list all tabs
playwright-cli tab-new [url] # create a new tab
playwright-cli tab-close [index] # close a browser tab
playwright-cli tab-select <index> # select a browser tab
```
### Storage
[Permalink: Storage](https://github.com/microsoft/playwright-cli#storage)
```
playwright-cli state-save [filename] # save storage state
playwright-cli state-load <filename> # load storage state
# Cookies
playwright-cli cookie-list [--domain] # list cookies
playwright-cli cookie-get <name> # get a cookie
playwright-cli cookie-set <name> <val> # set a cookie
playwright-cli cookie-delete <name> # delete a cookie
playwright-cli cookie-clear # clear all cookies
# LocalStorage
playwright-cli localstorage-list # list localStorage entries
playwright-cli localstorage-get <key> # get localStorage value
playwright-cli localstorage-set <k> <v> # set localStorage value
playwright-cli localstorage-delete <k> # delete localStorage entry
playwright-cli localstorage-clear # clear all localStorage
# SessionStorage
playwright-cli sessionstorage-list # list sessionStorage entries
playwright-cli sessionstorage-get <k> # get sessionStorage value
playwright-cli sessionstorage-set <k> <v> # set sessionStorage value
playwright-cli sessionstorage-delete <k> # delete sessionStorage entry
playwright-cli sessionstorage-clear # clear all sessionStorage
```
### Network
[Permalink: Network](https://github.com/microsoft/playwright-cli#network)
```
playwright-cli route <pattern> [opts] # mock network requests
playwright-cli route-list # list active routes
playwright-cli unroute [pattern] # remove route(s)
```
### DevTools
[Permalink: DevTools](https://github.com/microsoft/playwright-cli#devtools)
```
playwright-cli console [min-level] # list console messages
playwright-cli network # list all network requests since loading the page
playwright-cli run-code <code> # run playwright code snippet
playwright-cli tracing-start # start trace recording
playwright-cli tracing-stop # stop trace recording
playwright-cli video-start # start video recording
playwright-cli video-stop [filename] # stop video recording
```
### Install
[Permalink: Install](https://github.com/microsoft/playwright-cli#install)
```
playwright-cli install --skills # install skills
playwright-cli install-browser # install browser
```
### Configuration
[Permalink: Configuration](https://github.com/microsoft/playwright-cli#configuration)
```
playwright-cli config [options] # configure session settings
playwright-cli open --browser=chrome # use specific browser
playwright-cli open --extension # connect via browser extension
playwright-cli open --persistent # use persistent profile
playwright-cli open --profile=<path> # use custom profile directory
playwright-cli open --config=file.json # use config file
playwright-cli close # close the browser
playwright-cli delete-data # delete user data for default session
```
### Sessions
[Permalink: Sessions](https://github.com/microsoft/playwright-cli#sessions-1)
```
playwright-cli -s=name <cmd> # run command in named session
playwright-cli -s=name close # stop a named browser
playwright-cli -s=name delete-data # delete user data for named browser
playwright-cli list # list all sessions
playwright-cli close-all # close all browsers
playwright-cli kill-all # forcefully kill all browser processes
```
## Configuration file
[Permalink: Configuration file](https://github.com/microsoft/playwright-cli#configuration-file)
The Playwright CLI can be configured using a JSON configuration file. You can specify the configuration file using the `--config` command line option:
```
playwright-cli --config path/to/config.json open example.com
```
Playwright CLI will load config from `playwright-cli.json` by default so that you did not need to specify it every time.
Configuration file schema
```
{
/**
* The browser to use.
*/
browser?: {
/**
* The type of browser to use.
*/
browserName?: 'chromium' | 'firefox' | 'webkit';
/**
* Keep the browser profile in memory, do not save it to disk.
*/
isolated?: boolean;
/**
* Path to a user data directory for browser profile persistence.
* Temporary directory is created by default.
*/
userDataDir?: string;
/**
* Launch options passed to
* @see https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context
*
* This is useful for settings options like `channel`, `headless`, `executablePath`, etc.
*/
launchOptions?: playwright.LaunchOptions;
/**
* Context options for the browser context.
*
* This is useful for settings options like `viewport`.
*/
contextOptions?: playwright.BrowserContextOptions;
/**
* Chrome DevTools Protocol endpoint to connect to an existing browser instance in case of Chromium family browsers.
*/
cdpEndpoint?: string;
/**
* CDP headers to send with the connect request.
*/
cdpHeaders?: Record<string, string>;
/**
* Timeout in milliseconds for connecting to CDP endpoint. Defaults to 30000 (30 seconds). Pass 0 to disable timeout.
*/
cdpTimeout?: number;
/**
* Remote endpoint to connect to an existing Playwright server.
*/
remoteEndpoint?: string;
/**
* Paths to TypeScript files to add as initialization scripts for Playwright page.
*/
initPage?: string[];
/**
* Paths to JavaScript files to add as initialization scripts.
* The scripts will be evaluated in every page before any of the page's scripts.
*/
initScript?: string[];
},
/**
* If specified, saves the Playwright video of the session into the output directory.
*/
saveVideo?: {
width: number;
height: number;
};
/**
* The directory to save output files.
*/
outputDir?: string;
/**
* Whether to save snapshots, console messages, network logs and other session logs to a file or to the standard output. Defaults to "stdout".
*/
outputMode?: 'file' | 'stdout';
console?: {
/**
* The level of console messages to return. Each level includes the messages of more severe levels. Defaults to "info".
*/
level?: 'error' | 'warning' | 'info' | 'debug';
},
network?: {
/**
* List of origins to allow the browser to request. Default is to allow all. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
*/
allowedOrigins?: string[];
/**
* List of origins to block the browser to request. Origins matching both `allowedOrigins` and `blockedOrigins` will be blocked.
*/
blockedOrigins?: string[];
};
/**
* Specify the attribute to use for test ids, defaults to "data-testid".
*/
testIdAttribute?: string;
timeouts?: {
/*
* Configures default action timeout: https://playwright.dev/docs/api/class-page#page-set-default-timeout. Defaults to 5000ms.
*/
action?: number;
/*
* Configures default navigation timeout: https://playwright.dev/docs/api/class-page#page-set-default-navigation-timeout. Defaults to 60000ms.
*/
navigation?: number;
};
/**
* Whether to allow file uploads from anywhere on the file system.
* By default (false), file uploads are restricted to paths within the MCP roots only.
*/
allowUnrestrictedFileAccess?: boolean;
/**
* Specify the language to use for code generation.
*/
codegen?: 'typescript' | 'none';
}
```
Configuration via env
| Environment |
| --- |
| `PLAYWRIGHT_MCP_ALLOWED_HOSTS` comma-separated list of hosts this server is allowed to serve from. Defaults to the host the server is bound to. Pass '\*' to disable the host check. |
| `PLAYWRIGHT_MCP_ALLOWED_ORIGINS` semicolon-separated list of TRUSTED origins to allow the browser to request. Default is to allow all. Important: _does not_ serve as a security boundary and _does not_ affect redirects. |
| `PLAYWRIGHT_MCP_ALLOW_UNRESTRICTED_FILE_ACCESS` allow access to files outside of the workspace roots. Also allows unrestricted access to file:// URLs. By default access to file system is restricted to workspace root directories (or cwd if no roots are configured) only, and navigation to file:// URLs is blocked. |
| `PLAYWRIGHT_MCP_BLOCKED_ORIGINS` semicolon-separated list of origins to block the browser from requesting. Blocklist is evaluated before allowlist. If used without the allowlist, requests not matching the blocklist are still allowed. Important: _does not_ serve as a security boundary and _does not_ affect redirects. |
| `PLAYWRIGHT_MCP_BLOCK_SERVICE_WORKERS` block service workers |
| `PLAYWRIGHT_MCP_BROWSER` browser or chrome channel to use, possible values: chrome, firefox, webkit, msedge. |
| `PLAYWRIGHT_MCP_CAPS` comma-separated list of additional capabilities to enable, possible values: vision, pdf. |
| `PLAYWRIGHT_MCP_CDP_ENDPOINT` CDP endpoint to connect to. |
| `PLAYWRIGHT_MCP_CDP_HEADER` CDP headers to send with the connect request, multiple can be specified. |
| `PLAYWRIGHT_MCP_CODEGEN` specify the language to use for code generation, possible values: "typescript", "none". Default is "typescript". |
| `PLAYWRIGHT_MCP_CONFIG` path to the configuration file. |
| `PLAYWRIGHT_MCP_CONSOLE_LEVEL` level of console messages to return: "error", "warning", "info", "debug". Each level includes the messages of more severe levels. |
| `PLAYWRIGHT_MCP_DEVICE` device to emulate, for example: "iPhone 15" |
| `PLAYWRIGHT_MCP_EXECUTABLE_PATH` path to the browser executable. |
| `PLAYWRIGHT_MCP_EXTENSION` Connect to a running browser instance (Edge/Chrome only). Requires the "Playwright MCP Bridge" browser extension to be installed. |
| `PLAYWRIGHT_MCP_GRANT_PERMISSIONS` List of permissions to grant to the browser context, for example "geolocation", "clipboard-read", "clipboard-write". |
| `PLAYWRIGHT_MCP_HEADLESS` run browser in headless mode, headed by default |
| `PLAYWRIGHT_MCP_HOST` host to bind server to. Default is localhost. Use 0.0.0.0 to bind to all interfaces. |
| `PLAYWRIGHT_MCP_IGNORE_HTTPS_ERRORS` ignore https errors |
| `PLAYWRIGHT_MCP_INIT_PAGE` path to TypeScript file to evaluate on Playwright page object |
| `PLAYWRIGHT_MCP_INIT_SCRIPT` path to JavaScript file to add as an initialization script. The script will be evaluated in every page before any of the page's scripts. Can be specified multiple times. |
| `PLAYWRIGHT_MCP_ISOLATED` keep the browser profile in memory, do not save it to disk. |
| `PLAYWRIGHT_MCP_IMAGE_RESPONSES` whether to send image responses to the client. Can be "allow" or "omit", Defaults to "allow". |
| `PLAYWRIGHT_MCP_NO_SANDBOX` disable the sandbox for all process types that are normally sandboxed. |
| `PLAYWRIGHT_MCP_OUTPUT_DIR` path to the directory for output files. |
| `PLAYWRIGHT_MCP_OUTPUT_MODE` whether to save snapshots, console messages, network logs to a file or to the standard output. Can be "file" or "stdout". Default is "stdout". |
| `PLAYWRIGHT_MCP_PORT` port to listen on for SSE transport. |
| `PLAYWRIGHT_MCP_PROXY_BYPASS` comma-separated domains to bypass proxy, for example ".com,chromium.org,.domain.com" |
| `PLAYWRIGHT_MCP_PROXY_SERVER` specify proxy server, for example " [http://myproxy:3128](http://myproxy:3128/)" or "socks5://myproxy:8080" |
| `PLAYWRIGHT_MCP_SAVE_SESSION` Whether to save the Playwright MCP session into the output directory. |
| `PLAYWRIGHT_MCP_SAVE_TRACE` Whether to save the Playwright Trace of the session into the output directory. |
| `PLAYWRIGHT_MCP_SAVE_VIDEO` Whether to save the video of the session into the output directory. For example "--save-video=800x600" |
| `PLAYWRIGHT_MCP_SECRETS` path to a file containing secrets in the dotenv format |
| `PLAYWRIGHT_MCP_SHARED_BROWSER_CONTEXT` reuse the same browser context between all connected HTTP clients. |
| `PLAYWRIGHT_MCP_SNAPSHOT_MODE` when taking snapshots for responses, specifies the mode to use. Can be "incremental", "full", or "none". Default is incremental. |
| `PLAYWRIGHT_MCP_STORAGE_STATE` path to the storage state file for isolated sessions. |
| `PLAYWRIGHT_MCP_TEST_ID_ATTRIBUTE` specify the attribute to use for test ids, defaults to "data-testid" |
| `PLAYWRIGHT_MCP_TIMEOUT_ACTION` specify action timeout in milliseconds, defaults to 5000ms |
| `PLAYWRIGHT_MCP_TIMEOUT_NAVIGATION` specify navigation timeout in milliseconds, defaults to 60000ms |
| `PLAYWRIGHT_MCP_USER_AGENT` specify user agent string |
| `PLAYWRIGHT_MCP_USER_DATA_DIR` path to the user data directory. If not specified, a temporary directory will be created. |
| `PLAYWRIGHT_MCP_VIEWPORT_SIZE` specify browser viewport size in pixels, for example "1280x720" |
## Specific tasks
[Permalink: Specific tasks](https://github.com/microsoft/playwright-cli#specific-tasks)
The installed skill includes detailed reference guides for common tasks:
- **Request mocking** — intercept and mock network requests
- **Running Playwright code** — execute arbitrary Playwright scripts
- **Browser session management** — manage multiple browser sessions
- **Storage state (cookies, localStorage)** — persist and restore browser state
- **Test generation** — generate Playwright tests from interactions
- **Tracing** — record and inspect execution traces
- **Video recording** — capture browser session videos
## About
CLI for common Playwright actions. Record and generate Playwright code, inspect selectors and take screenshots.
[playwright.dev](https://playwright.dev/ "https://playwright.dev")
### Topics
[playwright](https://github.com/topics/playwright "Topic: playwright")
### Resources
[Readme](https://github.com/microsoft/playwright-cli#readme-ov-file)
### License
[Apache-2.0 license](https://github.com/microsoft/playwright-cli#Apache-2.0-1-ov-file)
### Code of conduct
[Code of conduct](https://github.com/microsoft/playwright-cli#coc-ov-file)
### Contributing
[Contributing](https://github.com/microsoft/playwright-cli#contributing-ov-file)
### Security policy
[Security policy](https://github.com/microsoft/playwright-cli#security-ov-file)
### Uh oh!
There was an error while loading. [Please reload this page](https://github.com/microsoft/playwright-cli).
[Activity](https://github.com/microsoft/playwright-cli/activity)
[Custom properties](https://github.com/microsoft/playwright-cli/custom-properties)
### Stars
[**2.7k**\\
stars](https://github.com/microsoft/playwright-cli/stargazers)
### Watchers
[**26**\\
watching](https://github.com/microsoft/playwright-cli/watchers)
### Forks
[**108**\\
forks](https://github.com/microsoft/playwright-cli/forks)
[Report repository](https://github.com/contact/report-content?content_url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fplaywright-cli&report=microsoft+%28user%29)
## [Releases\ 3](https://github.com/microsoft/playwright-cli/releases)
[v0.1.0\\
Latest\\
\\
2 days agoFeb 7, 2026](https://github.com/microsoft/playwright-cli/releases/tag/v0.1.0)
[\+ 2 releases](https://github.com/microsoft/playwright-cli/releases)
## [Packages\ 0](https://github.com/orgs/microsoft/packages?repo_name=playwright-cli)
No packages published
## [Used by 227](https://github.com/microsoft/playwright-cli/network/dependents)
[- \\
- \\
- \\
- \\
- \\
- \\
\\
\+ 219](https://github.com/microsoft/playwright-cli/network/dependents)
## [Contributors\ 5](https://github.com/microsoft/playwright-cli/graphs/contributors)
- [](https://github.com/pavelfeldman)
- [](https://github.com/Skn0tt)
- [](https://github.com/yury-s)
- [](https://github.com/vsantele)
- [](https://github.com/salmanmkc)
## Languages
- [JavaScript52.8%](https://github.com/microsoft/playwright-cli/search?l=javascript)
- [TypeScript47.2%](https://github.com/microsoft/playwright-cli/search?l=typescript)
You can’t perform that action at this time.SKILL.md
---
name: playwright-bowser
description: Headless browser automation using Playwright CLI. Use when you need headless browsing, parallel browser sessions, UI testing, screenshots, web scraping, or browser automation that can run in the background. Keywords - playwright, headless, browser, test, screenshot, scrape, parallel.
allowed-tools: Bash
---
# Playwright Bowser
## Purpose
Automate browsers using `playwright-cli` — a token-efficient CLI for Playwright. Runs headless by default, supports parallel sessions via named sessions (`-s=`), and doesn't load tool schemas into context.
## Key Details
- **Headless by default** — pass `--headed` to `open` to see the browser
- **Parallel sessions** — use `-s=<name>` to run multiple independent browser instances
- **Persistent profiles** — cookies and storage state preserved between calls
- **Token-efficient** — CLI-based, no accessibility trees or tool schemas in context
- **Vision mode** (opt-in) — set `PLAYWRIGHT_MCP_CAPS=vision` to receive screenshots as image responses in context instead of just saving to disk
## Sessions
**Always use a named session.** Derive a short, descriptive kebab-case name from the user's prompt. This gives each task a persistent browser profile (cookies, localStorage, history) that accumulates across calls.
```bash
# Derive session name from prompt context:
# "test the checkout flow on mystore.com" → -s=mystore-checkout
# "scrape pricing from competitor.com" → -s=competitor-pricing
# "UI test the login page" → -s=login-ui-test
playwright-cli -s=mystore-checkout open https://mystore.com --persistent
playwright-cli -s=mystore-checkout snapshot
playwright-cli -s=mystore-checkout click e12
```
Managing sessions:
```bash
playwright-cli list # list all sessions
playwright-cli close-all # close all sessions
playwright-cli -s=<name> close # close specific session
playwright-cli -s=<name> delete-data # wipe session profile
```
## Quick Reference
```
Core: open [url], goto <url>, click <ref>, fill <ref> <text>, type <text>, snapshot, screenshot [ref], close
Navigate: go-back, go-forward, reload
Keyboard: press <key>, keydown <key>, keyup <key>
Mouse: mousemove <x> <y>, mousedown, mouseup, mousewheel <dx> <dy>
Tabs: tab-list, tab-new [url], tab-close [index], tab-select <index>
Save: screenshot [ref], pdf, screenshot --filename=f
Storage: state-save, state-load, cookie-*, localstorage-*, sessionstorage-*
Network: route <pattern>, route-list, unroute, network
DevTools: console, run-code <code>, tracing-start/stop, video-start/stop
Sessions: -s=<name> <cmd>, list, close-all, kill-all
Config: open --headed, open --browser=chrome, resize <w> <h>
```
## Workflow
1. Derive a session name from the user's prompt and open with `--persistent` to preserve cookies/state. Always set the viewport via env var at launch:
```bash
PLAYWRIGHT_MCP_VIEWPORT_SIZE=1440x900 playwright-cli -s=<session-name> open <url> --persistent
# or headed:
PLAYWRIGHT_MCP_VIEWPORT_SIZE=1440x900 playwright-cli -s=<session-name> open <url> --persistent --headed
# or with vision (screenshots returned as image responses in context):
PLAYWRIGHT_MCP_VIEWPORT_SIZE=1440x900 PLAYWRIGHT_MCP_CAPS=vision playwright-cli -s=<session-name> open <url> --persistent
```
3. Get element references via snapshot:
```bash
playwright-cli snapshot
```
4. Interact using refs from snapshot:
```bash
playwright-cli click <ref>
playwright-cli fill <ref> "text"
playwright-cli type "text"
playwright-cli press Enter
```
5. Capture results:
```bash
playwright-cli screenshot
playwright-cli screenshot --filename=output.png
```
6. **Always close the session when done.** This is not optional — close the named session after finishing your task:
```bash
playwright-cli -s=<session-name> close
```
## Configuration
If a `playwright-cli.json` exists in the working directory, use it automatically. If the user provides a path to a config file, use `--config path/to/config.json`. Otherwise, skip configuration — the env var and CLI defaults are sufficient.
```json
{
"browser": {
"browserName": "chromium",
"launchOptions": { "headless": true },
"contextOptions": { "viewport": { "width": 1440, "height": 900 } }
},
"outputDir": "./screenshots"
}
```
## Full Help
Run `playwright-cli --help` or `playwright-cli --help <command>` for detailed command usage.
See [docs/playwright-cli.md](docs/playwright-cli.md) for full documentation.