playwright-cli
Skill1 starsChanged 8 months agoMITView on GitHub
浏览器自动化 CLI 工具,使用 Playwright 控制浏览器进行网页操作。 支持 Chrome、Firefox、Safari 多浏览器,支持导航、截图、点击、填写表单、执行 JavaScript 等操作。 当用户需要:网页截图、打开网页、浏览器自动化、网页操作、点击元素、填写表单、测试网页、抓取网页数据时,**必须**使用此 Skill。 相比 Puppeteer,Playwright 支持更多浏览器(Chrome/Firefox/Safari),更好的跨浏览器测试能力。 特别适用于:跨浏览器测试、网页截图分析、表单自动填写、网页数据提取、网页测试。
- Installs packages
180 other projects use a version of this.
Adopted by
Most recently taken up by
- idavidov13/agentic-playwrighttheir own version, first seen Nov 8, 2026
- kurofune/claudittheir own version, first seen Nov 8, 2026
- naman10parikh/pennytheir own version, first seen Nov 8, 2026
- n1kben/agentstheir own version, first seen Nov 8, 2026
- Today-Weekly-Release-Company/codex-inittheir own version, first seen Nov 8, 2026
- taixuann/development-spacetheir own version, first seen Nov 8, 2026
Used with
Projects with it also use fabric-sdk, ecosystem-reference and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillfabric-sdk
How to use @microsoft/fabric-app-data to connect web applications to Fabric data sources at runtime. Build browser-based apps that query semantic models via DAX using the FabricClient API.
Also in 9 projects that use this
naman10parikhSkillecosystem-reference
Quick-access directory of Claude Code ecosystem repos, skills, plugins, MCPs, and patterns. Use when improving the harness.
Also in 5 projects that use this
naman10parikhSkillfractal-delegation
Also in 5 projects that use this
MicrosoftSkillschema-discovery
Explore Power BI semantic model schemas using DAX INFO functions. Progressive metadata discovery strategy, scope estimation, and narrowing techniques for tables, columns, measures, and relationships.
Also in 9 projects that use this
- +6 more from naman10parikh
- +2 more from microsoft
Other versions180 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 180
- microsoft/playwright★ 100ksame name
- coleam00/Archon★ 24ksame name
- microsoft/playwright-cli★ 15ksame name
- dotnet/eShop★ 11ksame name
- TypeCellOS/BlockNote★ 10ksame name
- sanity-io/sanity★ 6.4ksame name
- github/gh-aw★ 5.6ksame name
- zebbern/claude-code-guide★ 4.7ksame name
- pwndoc/pwndoc★ 2.9ksame name
- jdecked/twemoji★ 1.9ksame name
170 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository40 other files it gives its agents.
- ralphSkill
- prdSkill
- th-prd-driven-dev-workflowSkill
- th-ralph-evoSkill
- th-ralphSkill
- th-workflow-decision-engineSkill
- agent-factorySkill
- arch-linuxSkill
- article-writingSkill
- browser-useSkill
- code-reviewSkill
- decision-recordSkill
- githubSkill
- knowledge-hubSkill
- long-doc-generatorSkill
- long-running-agentSkill
- th-model-compare-searchSkill
- newapi-cliSkill
- orchestratorSkill
- prd-evolutionSkill
- prd-to-codeSkill
- prompt-expertSkill
- prompt-optimizerSkill
- puppeteer-cliSkill
- ralphSkill
- prdSkill
- requirement-to-prdSkill
- site-analyzerSkill
- skill-creatorSkill
- skill-stocktakeSkill
- src-linkSkill
- th-bug-analyzerSkill
- th-deep-coder2Skill
- th-deep-coderSkill
- th-enterprise-test-agentSkill
- gitnexus-assistantSkill
- th-ralph-evoSkill
- th-ralphSkill
- unified-searchSkill
- web-fetchSkill
The file
Files
Playwright CLI Skill
浏览器自动化 CLI 工具,封装 Playwright 功能,支持多浏览器(Chrome/Firefox/Safari),支持导航、截图、点击、填写表单等操作。
为什么选择 Playwright?
| 特性 | Playwright | Puppeteer |
| 浏览器支持 | Chrome, Firefox, Safari | Chrome only |
| 跨浏览器测试 | ✅ 原生支持 | ❌ 需额外配置 |
| 自动等待 | ✅ 内置智能等待 | ❌ 需手动处理 |
| 移动端模拟 | ✅ 完善的设备库 | ⚠️ 基础支持 |
| 稳定性 | ✅ 更稳定的API | ⚠️ 偶有不稳定 |
安装依赖
npm install -g playwright
# 安装浏览器
npx playwright install chromium firefox webkit或者本地安装:
npm install playwright
npx playwright install使用方法
选项
| 选项 | 说明 |
--headed | 使用有界面模式 |
--headless | 使用无头模式(默认) |
--browser <name> | 选择浏览器: chromium/firefox/webkit (默认: chromium) |
--viewport <w>x<h> | 设置视口大小,如 1280x720 |
--mobile <device> | 模拟移动设备,如 "iPhone 14" |
--slowmo <ms> | 慢动作执行,毫秒 |
导航到网页
# 默认 Chromium 无头模式
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com
# 有界面模式
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://github.com --headed
# 使用 Firefox
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --browser firefox
# 使用 Safari (WebKit)
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --browser webkit截取屏幕截图
# 基本截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot myshot
# 全页面截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot myshot --fullpage
# 有界面模式(推荐用于复杂网站)
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot myshot --headed
# 自定义尺寸
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot myshot --viewport 1920x1080
# 移动端截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot mobile --mobile "iPhone 14"
# 跨浏览器截图(生成3张)
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot cross-browser --cross-browser点击元素
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs click "button#submit"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs click "text=Login"填写表单
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs fill "input[name=email]" "test@example.com"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs fill "#password" "secret123"选择下拉菜单
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs select "select#country" "CN"悬停元素
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs hover "div.menu-item"执行 JavaScript
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs evaluate "document.title"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs evaluate "() => { return document.querySelectorAll('h1').length; }"等待元素
# 等待元素可见
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait "#content" --state visible
# 等待元素隐藏
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait "#loading" --state hidden
# 等待超时
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait "#result" --timeout 10000获取元素文本
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs text "h1"获取元素属性
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs attr "img#logo" src键盘操作
# 按下按键
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs press Enter
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs press "Control+a"滚动页面
# 滚动到底部
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs scroll-to-bottom
# 滚动到元素
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs scroll-to "#footer"跨浏览器测试
# 在3个浏览器上运行同一测试
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs cross-browser-test https://example.com \
--actions 'navigate,screenshot,click "#btn",screenshot'关闭浏览器
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs close快捷别名建议
添加到 ~/.config/fish/config.fish 或 ~/.bashrc:
# Fish
alias playwright-cli="node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs"
alias pw="node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs"
alias pw-shot="node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot"
alias pw-nav="node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate"
# Bash/Zsh
alias playwright-cli='node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs'
alias pw='node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs'
alias pw-shot='node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot'
alias pw-nav='node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate'环境变量
| 变量 | 说明 |
PLAYWRIGHT_BROWSERS_PATH | 浏览器可执行文件路径 |
PLAYWRIGHT_HEADLESS | 设置默认 headless 模式 |
PLAYWRIGHT_SLOWMO | 慢动作执行毫秒数 |
完整命令列表
| 命令 | 别名 | 说明 |
navigate <url> | nav, goto | 导航到 URL |
screenshot [name] | shot, ss | 截图 |
click <selector> | - | 点击元素 |
fill <selector> <value> | type, input | 填写输入框 |
select <selector> <value> | - | 选择下拉菜单 |
hover <selector> | - | 悬停元素 |
evaluate <code> | eval, js | 执行 JS |
wait <selector> | - | 等待元素 |
text <selector> | - | 获取文本 |
attr <selector> <name> | - | 获取属性 |
press <key> | - | 按下按键 |
scroll-to <selector> | - | 滚动到元素 |
scroll-to-bottom | - | 滚动到底部 |
cross-browser-test <url> | - | 跨浏览器测试 |
close | exit, quit | 关闭浏览器 |
使用场景示例
场景 1:跨浏览器截图对比
# 在 Chrome 中截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --browser chromium --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot chrome --fullpage
# 在 Firefox 中截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --browser firefox --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot firefox --fullpage
# 在 Safari 中截图
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --browser webkit --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot safari --fullpage场景 2:移动端测试
# iPhone 14
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --mobile "iPhone 14" --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot iphone
# iPad
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --mobile "iPad Pro 11" --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot ipad
# Pixel 5
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --mobile "Pixel 5" --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot pixel场景 3:自动化表单填写
# 导航到登录页
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com/login --headed
# 填写表单
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs fill "input#username" "myuser"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs fill "#password" "mypass"
# 点击登录
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs click "button[type=submit]"
# 等待加载
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait "#dashboard" --state visible
# 截图结果
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot logged-in --fullpage场景 4:执行 JavaScript 获取数据
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs evaluate "() => {
const links = Array.from(document.querySelectorAll('a'));
return links.map(a => ({ text: a.textContent, href: a.href }));
}"场景 5:完整 E2E 测试流程
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --headed
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot 01-homepage
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs click "a[href='/products']"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait ".product-list"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot 02-products
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs click ".product-item:first-child"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs wait "#product-detail"
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs screenshot 03-product-detail支持的移动设备
常见设备名称:
"iPhone 14","iPhone 14 Pro","iPhone 14 Pro Max""iPhone 13","iPhone 13 Pro""iPhone SE""iPad Pro 11","iPad Pro 12.9","iPad Mini""Pixel 5","Pixel 7","Pixel 7 Pro""Galaxy S21","Galaxy S22"
查看完整列表:
npx playwright devices故障排除
浏览器未安装
# 安装所有浏览器
npx playwright install
# 或只安装特定浏览器
npx playwright install chromium
npx playwright install firefox
npx playwright install webkit依赖缺失 (Linux)
# Ubuntu/Debian
sudo apt-get install libnss3 libatk-bridge2.0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2
# Arch Linux
sudo pacman -S nss at-spi2-atk libxcomposite libxdamage libxfixes libxrandr mesa alsa-lib权限问题
# 给浏览器目录添加执行权限
chmod +x ~/.cache/ms-playwright/*/chrome-linux/chrome内存不足
# 使用更轻量的配置
node ~/.claude/skills/playwright-cli/scripts/playwright-cli.mjs navigate https://example.com --headless与 Puppeteer 对比
| 场景 | 推荐工具 |
| 只需要 Chrome 支持 | Puppeteer |
| 需要跨浏览器测试 | Playwright |
| 复杂 SPA 应用 | Playwright(自动等待更好) |
| 简单截图/抓取 | 两者皆可 |
| 移动端测试 | Playwright(设备库更丰富) |
| CI/CD 集成 | Playwright(更稳定) |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

