chore: update skill files

This commit is contained in:
Pavel Feldman
2026-02-06 10:27:20 -08:00
parent 3ed6f7558a
commit 4fafcccadd
4 changed files with 118 additions and 93 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ async function main() {
// 3. Move generated skills into the existing skills folder
console.log('\n=== Updating skills folder ===\n');
const generatedSkillsDir = path.join(rootDir, '.claude', 'skills', 'playwright');
const generatedSkillsDir = path.join(rootDir, '.claude', 'skills', 'playwright-cli');
const targetSkillsDir = path.join(skillsDir, 'playwright-cli');
try {
+43 -24
View File
@@ -9,25 +9,29 @@ allowed-tools: Bash(playwright-cli:*)
## Quick start
```bash
playwright-cli open https://playwright.dev
# open new browser
playwright-cli open
# navigate to a page
playwright-cli goto https://playwright.dev
# interact with the page using refs from the snapshot
playwright-cli click e15
playwright-cli type "page.click"
playwright-cli press Enter
# take a screenshot
playwright-cli screenshot
# close the browser
playwright-cli close
```
## Core workflow
1. Navigate: `playwright-cli open https://example.com`
2. Interact using refs from the snapshot
3. Re-snapshot after significant changes
## Commands
### Core
```bash
playwright-cli open
# open and navigate right away
playwright-cli open https://example.com/
playwright-cli close
playwright-cli goto https://playwright.dev
playwright-cli type "search query"
playwright-cli click e3
playwright-cli dblclick e7
@@ -46,6 +50,7 @@ playwright-cli dialog-accept
playwright-cli dialog-accept "confirmation text"
playwright-cli dialog-dismiss
playwright-cli resize 1920 1080
playwright-cli close
```
### Navigation
@@ -167,26 +172,36 @@ playwright-cli open --browser=msedge
# Connect to browser via extension
playwright-cli open --extension
# Configure the session
playwright-cli config --config my-config.json
playwright-cli config --headed --in-memory --browser=firefox
# Configure named session
playwright-cli --session=mysession config my-config.json
# Start with configured session
# Use persistent profile (by default profile is in-memory)
playwright-cli open --persistent
# Use persistent profile with custom directory
playwright-cli open --profile=/path/to/profile
# Start with config file
playwright-cli open --config=my-config.json
# Close the browser
playwright-cli close
# Delete user data for the default session
playwright-cli delete-data
```
### Sessions
### Browser Sessions
```bash
playwright-cli --session=mysession open example.com
playwright-cli --session=mysession click e6
playwright-cli session-list
playwright-cli session-stop mysession
playwright-cli session-restart mysession
playwright-cli session-stop-all
playwright-cli session-delete
playwright-cli session-delete mysession
# create new browser session named "mysession" with persistent profile
playwright-cli -s=mysession open example.com --persistent
# same with manually specified profile directory (use when requested explicitly)
playwright-cli -s=mysession open example.com --profile=/path/to/profile
playwright-cli -s=mysession click e6
playwright-cli -s=mysession close # stop a named browser
playwright-cli -s=mysession delete-data # delete user data for persistent session
playwright-cli list
# Close all browsers
playwright-cli close-all
# Forcefully kill all browser processes
playwright-cli kill-all
```
## Example: Form submission
@@ -199,6 +214,7 @@ playwright-cli fill e1 "user@example.com"
playwright-cli fill e2 "password123"
playwright-cli click e3
playwright-cli snapshot
playwright-cli close
```
## Example: Multi-tab workflow
@@ -209,6 +225,7 @@ playwright-cli tab-new https://example.com/other
playwright-cli tab-list
playwright-cli tab-select 0
playwright-cli snapshot
playwright-cli close
```
## Example: Debugging with DevTools
@@ -219,6 +236,7 @@ playwright-cli click e4
playwright-cli fill e7 "test"
playwright-cli console
playwright-cli network
playwright-cli close
```
```bash
@@ -227,13 +245,14 @@ playwright-cli tracing-start
playwright-cli click e4
playwright-cli fill e7 "test"
playwright-cli tracing-stop
playwright-cli close
```
## Specific tasks
* **Request mocking** [references/request-mocking.md](references/request-mocking.md)
* **Running Playwright code** [references/running-code.md](references/running-code.md)
* **Session management** [references/session-management.md](references/session-management.md)
* **Browser session management** [references/session-management.md](references/session-management.md)
* **Storage state (cookies, localStorage)** [references/storage-state.md](references/storage-state.md)
* **Test generation** [references/test-generation.md](references/test-generation.md)
* **Tracing** [references/tracing.md](references/tracing.md)
@@ -1,26 +1,26 @@
# Session Management
# Browser Session Management
Run multiple isolated browser sessions concurrently with state persistence.
## Named Sessions
## Named Browser Sessions
Use `--session` flag to isolate browser contexts:
Use `-b` flag to isolate browser contexts:
```bash
# Session 1: Authentication flow
playwright-cli --session=auth open https://app.example.com/login
# Browser 1: Authentication flow
playwright-cli -s=auth open https://app.example.com/login
# Session 2: Public browsing (separate cookies, storage)
playwright-cli --session=public open https://example.com
# Browser 2: Public browsing (separate cookies, storage)
playwright-cli -s=public open https://example.com
# Commands are isolated by session
playwright-cli --session=auth fill e1 "user@example.com"
playwright-cli --session=public snapshot
# Commands are isolated by browser session
playwright-cli -s=auth fill e1 "user@example.com"
playwright-cli -s=public snapshot
```
## Session Isolation Properties
## Browser Session Isolation Properties
Each session has independent:
Each browser session has independent:
- Cookies
- LocalStorage / SessionStorage
- IndexedDB
@@ -28,28 +28,30 @@ Each session has independent:
- Browsing history
- Open tabs
## Session Commands
## Browser Session Commands
```bash
# List all sessions
playwright-cli session-list
# List all browser sessions
playwright-cli list
# Stop a specific session
playwright-cli session-stop mysession
# Stop a browser session (close the browser)
playwright-cli close # stop the default browser
playwright-cli -s=mysession close # stop a named browser
# Stop all sessions
playwright-cli session-stop-all
# Stop all browser sessions
playwright-cli close-all
# Restart a session (useful after version updates)
playwright-cli session-restart mysession
# Forcefully kill all daemon processes (for stale/zombie processes)
playwright-cli kill-all
# Delete session data (cookies, storage, etc.)
playwright-cli session-delete mysession
# Delete browser session user data (profile directory)
playwright-cli delete-data # delete default browser data
playwright-cli -s=mysession delete-data # delete named browser data
```
## Environment Variable
Set a default session name via environment variable:
Set a default browser session name via environment variable:
```bash
export PLAYWRIGHT_CLI_SESSION="mysession"
@@ -64,100 +66,104 @@ playwright-cli open example.com # Uses "mysession" automatically
#!/bin/bash
# Scrape multiple sites concurrently
# Start all sessions
playwright-cli --session=site1 open https://site1.com &
playwright-cli --session=site2 open https://site2.com &
playwright-cli --session=site3 open https://site3.com &
# Start all browsers
playwright-cli -s=site1 open https://site1.com &
playwright-cli -s=site2 open https://site2.com &
playwright-cli -s=site3 open https://site3.com &
wait
# Take snapshots from each
playwright-cli --session=site1 snapshot
playwright-cli --session=site2 snapshot
playwright-cli --session=site3 snapshot
playwright-cli -s=site1 snapshot
playwright-cli -s=site2 snapshot
playwright-cli -s=site3 snapshot
# Cleanup
playwright-cli --session=site1 close
playwright-cli --session=site2 close
playwright-cli --session=site3 close
playwright-cli close-all
```
### A/B Testing Sessions
```bash
# Test different user experiences
playwright-cli --session=variant-a open "https://app.com?variant=a"
playwright-cli --session=variant-b open "https://app.com?variant=b"
playwright-cli -s=variant-a open "https://app.com?variant=a"
playwright-cli -s=variant-b open "https://app.com?variant=b"
# Compare
playwright-cli --session=variant-a screenshot
playwright-cli --session=variant-b screenshot
playwright-cli -s=variant-a screenshot
playwright-cli -s=variant-b screenshot
```
### Testing without persistent profile
### Persistent Profile
Use `--in-memory` flag to keep the browser profile in memory only:
By default, browser profile is kept in memory only. Use `--persistent` flag on `open` to persist the browser profile to disk:
```bash
# Session data won't persist to disk
playwright-cli --in-memory open https://example.com
# Use persistent profile (auto-generated location)
playwright-cli open https://example.com --persistent
# Use persistent profile with custom directory
playwright-cli open https://example.com --profile=/path/to/profile
```
## Default Session
## Default Browser Session
When `--session` is omitted, commands use the default session:
When `-s` is omitted, commands use the default browser session:
```bash
# These use the same default session
# These use the same default browser session
playwright-cli open https://example.com
playwright-cli snapshot
playwright-cli close # Closes default session
playwright-cli close # Stops default browser
```
## Session Configuration
## Browser Session Configuration
Configure a session with specific settings:
Configure a browser session with specific settings when opening:
```bash
# Configure session with config file
playwright-cli --session=mysession config --config=playwright-cli.json
# Open with config file
playwright-cli open https://example.com --config=.playwright/my-cli.json
# Configure session with specific browser
playwright-cli --session=mysession config --browser=firefox
# Open with specific browser
playwright-cli open https://example.com --browser=firefox
# Configure session in headed mode
playwright-cli --session=mysession config --headed
# Open in headed mode
playwright-cli open https://example.com --headed
# Restart session to apply changes
playwright-cli session-restart mysession
# Open with persistent profile
playwright-cli open https://example.com --persistent
```
## Best Practices
### 1. Name Sessions Semantically
### 1. Name Browser Sessions Semantically
```bash
# GOOD: Clear purpose
playwright-cli --session=github-auth open https://github.com
playwright-cli --session=docs-scrape open https://docs.example.com
playwright-cli -s=github-auth open https://github.com
playwright-cli -s=docs-scrape open https://docs.example.com
# AVOID: Generic names
playwright-cli --session=s1 open https://github.com
playwright-cli -s=s1 open https://github.com
```
### 2. Always Clean Up
```bash
# Stop sessions when done
playwright-cli session-stop auth
playwright-cli session-stop scrape
# Stop browsers when done
playwright-cli -s=auth close
playwright-cli -s=scrape close
# Or stop all at once
playwright-cli session-stop-all
playwright-cli close-all
# If browsers become unresponsive or zombie processes remain
playwright-cli kill-all
```
### 3. Delete Stale Session Data
### 3. Delete Stale Browser Data
```bash
# Remove old session data to free disk space
playwright-cli session-delete oldsession
# Remove old browser data to free disk space
playwright-cli -s=oldsession delete-data
```
@@ -272,4 +272,4 @@ playwright-cli open https://example.com
- Add `*.auth-state.json` to `.gitignore`
- Delete state files after automation completes
- Use environment variables for sensitive data
- Consider using `--in-memory` mode for sensitive operations
- By default, sessions run in-memory mode which is safer for sensitive operations