Skip to main content

playwright-browser

Headless browser automation using Playwright CLI. Use for browser testing, screenshots, scraping, and parallel browser sessions. Token-efficient CLI — no MCP overhead.

来源信息

仓库
orakitine/claude-code-lab
最近来源活动
2026年3月2日 04:57
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
Playwright Browser
description
Headless browser automation using Playwright CLI. Use for browser testing, screenshots, scraping, and parallel browser sessions. Token-efficient CLI — no MCP overhead.
trigger
auto
allowed-tools
["Bash","Read","Write"]
# Purpose Automate browsers using `playwright-cli`, a token-efficient CLI for Playwright. Runs headless by default, supports parallel sessions via named sessions (`-s=`), and persistent profiles for cookies/state. Use when you need headless browsing, UI testing, screenshots, web scraping, or any browser automation that can run in the background. ## Variables HEADED: false # Show browser window. Options: true, false VISION: false # Return screenshots as images in context (higher token cost) VIEWPORT_SIZE: 1440x900 # Browser viewport dimensions (WxH) SCREENSHOTS_DIR: ./screenshots # Where screenshots are saved ## Workflow 1. **Open Session** - Derive a short kebab-case session name from the user's prompt - Open with `--persistent` to preserve cookies/localStorage across commands - Example: "test checkout on mystore.com" → `-s=mystore-checkout` - Example: "scrape pricing from competitor.com" → `-s=competitor-pricing` - IF: HEADED is true → add `--headed` flag - IF: VISION is true → prefix with `PLAYWRIGHT_MCP_CAPS=vision` - Tool: Bash ``` PLAYWRIGHT_MCP_VIEWPORT_SIZE=<VIEWPORT_SIZE> playwright-cli -s=<session-name> open <url> --persistent ``` - Headed example: ``` PLAYWRIGHT_MCP_VIEWPORT_SIZE=1440x900 playwright-cli -s=mystore-checkout open https://mystore.com --persistent --headed ``` 2. **Snapshot Page** - Capture element references to identify interactive elements - Returns a list of refs (e.g., `e12`, `e45`) you can click, fill, etc. - Example: `playwright-cli -s=mystore-checkout snapshot` → returns element tree with refs - Tool: Bash `playwright-cli -s=<session-name> snapshot` 3. **Interact with Elements** - Use refs from snapshot to click, fill, type, select, hover - Example: `playwright-cli -s=mystore-checkout click e12` → clicks element ref e12 - Example: `playwright-cli -s=mystore-checkout fill e15 "test@example.com"` → fills input - Example: `playwright-cli -s=mystore-checkout type "search query"` → types into focused element - Example: `playwright-cli -s=mystore-checkout press Enter` → presses keyboard key - Navigate: `goto <url>`, `go-back`, `go-forward`, `reload` - Tool: Bash `playwright-cli -s=<session-name> <command> <args>` 4. **Take Screenshots** - Capture current page state as PNG - IF: specific filename needed → use `--filename=<path>` - Example: `playwright-cli -s=mystore-checkout screenshot` → saves to default location - Example: `playwright-cli -s=mystore-checkout screenshot --filename=./screenshots/checkout-step1.png` - Tool: Bash `playwright-cli -s=<session-name> screenshot [--filename=<path>]` 5. **Close Session** - ALWAYS close the session when done — this is not optional - Example: `playwright-cli -s=mystore-checkout close` - To close ALL sessions: `playwright-cli close-all` - To wipe session data: `playwright-cli -s=<name> delete-data` - Tool: Bash `playwright-cli -s=<session-name> close` ## Additional Commands Reference | Command | Description | Example | |---------|-------------|---------| | `open [url]` | Launch browser | `-s=test open https://example.com --persistent` | | `close` | Close session | `-s=test close` | | `goto <url>` | Navigate to URL | `-s=test goto https://example.com/page2` | | `snapshot` | Get element refs | `-s=test snapshot` | | `screenshot` | Capture page image | `-s=test screenshot --filename=out.png` | | `click <ref>` | Click element | `-s=test click e12` | | `fill <ref> <text>` | Fill input field | `-s=test fill e15 "hello"` | | `type <text>` | Type into focused | `-s=test type "search"` | | `press <key>` | Press keyboard key | `-s=test press Enter` | | `hover <ref>` | Hover over element | `-s=test hover e20` | | `select <ref> <val>` | Select dropdown | `-s=test select e30 "option1"` | | `go-back` | Back | `-s=test go-back` | | `go-forward` | Forward | `-s=test go-forward` | | `reload` | Reload page | `-s=test reload` | | `tab-list` | List tabs | `-s=test tab-list` | | `tab-new [url]` | New tab | `-s=test tab-new https://example.com` | | `tab-select <i>` | Switch tab | `-s=test tab-select 1` | | `list` | List sessions | `list` | | `close-all` | Close all sessions | `close-all` | **Common flags**: `--persistent` (cookies/state), `--headed` (visible browser), `--browser=chrome`, `--filename=<path>`
在 GitHub 查看