🗄️ Browser storage & authentication state control
Full introspection and manipulation of browser storage, enabling reproducible auth flows, debugging, and stateful automation.
> playwright-cli state-save auth.json
> playwright-cli state-load auth.jsonInspect and manage cookies:
> playwright-cli cookie-list
> playwright-cli cookie-get session_id
> playwright-cli cookie-set session_id abc123 --domain=example.com
> playwright-cli cookie-delete session_id
> playwright-cli cookie-clearWork directly with Web Storage APIs:
# LocalStorage
> playwright-cli localstorage-list
> playwright-cli localstorage-get theme
> playwright-cli localstorage-set theme dark
> playwright-cli localstorage-clear
# SessionStorage
> playwright-cli sessionstorage-list
> playwright-cli sessionstorage-set wizardStep 3
> playwright-cli sessionstorage-clearPerfect for:
- Persisting login sessions
- Debugging auth and feature flags
- Sharing reproducible browser state across runs
🌐 Powerful network & API request mocking
Intercept, mock, modify, or block network requests directly from the CLI — no test harness required.
Simple CLI-based request mocking
Mock responses by URL pattern with custom status codes, bodies, headers, or request mutations.
# Mock with custom status
> playwright-cli route "**/*.jpg" --status=404
# Mock with JSON body
> playwright-cli route "**/api/users" \
--body='[{"id":1,"name":"Alice"}]' \
--content-type=application/json
# Mock with custom headers
> playwright-cli route "**/api/data" \
--body='{"ok":true}' \
--header="X-Custom: value"
# Strip sensitive headers from outgoing requests
> playwright-cli route "**/*" --remove-header=cookie,authorizationManage active routes:
> playwright-cli route-list
> playwright-cli unroute "**/*.jpg"
> playwright-cli unrouteUse cases:
- Frontend development without a backend
- Offline and error-state testing
- Snapshot stability and deterministic rendering
Flexible URL pattern matching
Routes support glob-style patterns for precise targeting:
**/api/users Exact path match
**/api/*/details Wildcards within paths
**/*.{png,jpg,jpeg} File extension matching
**/search?q=* Query parameter matching
🧠 Advanced request handling with run-code
For conditional logic, request inspection, response mutation, or timing control, drop down to raw Playwright routing via run-code.
Conditional responses based on request data
> playwright-cli run-code "async page => {
await page.route('**/api/login', route => {
const body = route.request().postDataJSON();
if (body.username === 'admin') {
route.fulfill({ body: JSON.stringify({ token: 'mock-token' }) });
} else {
route.fulfill({ status: 401, body: JSON.stringify({ error: 'Invalid' }) });
}
});
}"Modify real backend responses
> playwright-cli run-code "async page => {
await page.route('**/api/user', async route => {
const response = await route.fetch();
const json = await response.json();
json.isPremium = true;
await route.fulfill({ response, json });
});
}"Simulate network failures
> playwright-cli run-code "async page => {
await page.route('**/api/offline', route =>
route.abort('internetdisconnected')
);
}"🧠 SKILLS
Local SKILLS installation
> playwright-cli install-skillsOther
Browser installation (renamed)
> playwright-cli install-browserEphemeral browser contexts (renamed)
> playwright-cli config --in-memoryRenamed from --isolated to better reflect behavior:
- Browser profile lives only in memory
- Nothing persisted to disk
- Clean state on every run