测试24k · #10123
playwright-cli
它能做什么
这项技能教 AI 智能体使用简单的命令驱动真实的浏览器,包括打开页面、填写表单和检查结果。适合测试网站或自动化重复性浏览器任务的人。
适用场景
- ✓当你希望智能体打开网站并点击、填写表单时。
- ✓当你需要检查网页是否显示了正确的文字或行为是否正确时。
- ✓当你想自动化在浏览器中反复进行的任务时。
技能链接
https://github.com/coleam00/Archon/blob/dev/.claude/skills/playwright-cli/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
请用这个技能帮我:https://github.com/coleam00/Archon/blob/dev/.claude/skills/playwright-cli/SKILL.md
阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
npx skills add coleam00/Archon --skill playwright-cli
下载 SKILL.md,放进智能体的技能文件夹。
curl -L https://raw.githubusercontent.com/coleam00/Archon/dev/.claude/skills/playwright-cli/SKILL.md -o SKILL.md
可以这样问 AI
“请打开我们的预发布网站,填写联系表单,并告诉我是否出现了确认消息。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会打开浏览器,读取页面快照中的元素引用,然后利用这些引用进行点击、输入并检查结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Browser Automation with playwright-cli
Quick start
# 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 (rarely used, as snapshot is more common)
playwright-cli screenshot
# close the browser
playwright-cli close
Commands
Core
playwright-cli open
# open and navigate right away
playwright-cli open https://example.com/
playwright-cli goto https://playwright.dev
playwright-cli type "search query"
playwright-cli click e3
playwright-cli dblclick e7
# --submit presses Enter after filling the element
playwright-cli fill e5 "user@example.com" --submit
playwright-cli drag e2 e8
# drop files or data onto an element (from outside the page)
playwright-cli drop e4 --path=./image.png
playwright-cli drop e4 --data="text/plain=hello world"
playwright-cli hover e4
playwright-cli select e9 "option-value"
playwright-cli upload ./document.pdf
playwright-cli check e12
playwright-cli uncheck e12
playwright-cli snapshot
# search the snapshot for text or a regexp, returns matching nodes with surrounding context
playwright-cli find "Sign in"
playwright-cli find --regex "Sign (in|up)"
# wrap the regexp in slashes to add flags, e.g. /i for case-insensitive
playwright-cli find --regex "/sign (in|up)/i"
playwright-cli eval "document.title"
playwright-cli eval "el => el.textContent" e5
# get element id, class, or any attribute not visible in the snapshot
playwright-cli eval "el => el.id" e5
playwright-cli eval "el => el.getAttribute('data-testid')" e5
playwright-cli dialog-accept
playwright-cli dialog-accept "confirmation text"
playwright-cli dialog-dismiss
playwright-cli resize 1920 1080
playwright-cli close
Navigation
playwright-cli go-back
playwright-cli go-forward
playwright-cli reload
Keyboard
playwright-cli press Enter
playwright-cli press ArrowDown
playwright-cli keydown Shift
playwright-cli keyup Shift
Mouse
playwright-cli mousemove 150 300
playwright-cli mousedown
playwright-cli mousedown right
playwright-cli mouseup
playwright-cli mouseup right
playwright-cli mousewheel 0 100
Save as
playwright-cli screenshot
playwright-cli screenshot e5
playwright-cli screenshot --filename=page.png
playwright-cli screenshot --hires
playwright-cli pdf --filename=page.pdf
Tabs
playwright-cli tab-list
playwright-cli tab-new
playwright-cli tab-new https://example.com/page
playwright-cli tab-close
playwright-cli tab-close 2
playwright-cli tab-select 0
Storage
playwright-cli state-save
playwright-cli state-save auth.json
playwright-cli state-load auth.json
# Cookies
playwright-cli cookie-list
playwright-cli cookie-list --domain=example.com
playwright-cli cookie-get session_id
playwright-cli cookie-set session_id abc123
playwright-cli cookie-set session_id abc123 --domain=example.com --httpOnly --secure
playwright-cli cookie-delete session_id
playwright-cli cookie-clear
# LocalStorage
playwright-cli localstorage-list
playwright-cli localstorage-get theme
playwright-cli localstorage-set theme dark
playwright-cli localstorage-delete theme
playwright-cli localstorage-clear
# SessionStorage
playwright-cli sessionstorage-list
playwright-cli sessionstorage-get step
playwright-cli sessionstorage-set step 3
playwright-cli sessionstorage-delete step
playwright-cli sessionstorage-clear
Network
playwright-cli route "**/*.jpg" --status=404
playwright-cli route "https://api.example.com/**" --body='{"mock": true}'
playwright-cli route-list
playwright-cli unroute "**/*.jpg"
playwright-cli unroute
DevTools
playwright-cli console
playwright-cli console warning
playwright-cli requests
playwright-cli request 5
playwright-cli run-code "async page => await page.context().grantPermissions(['geolocation'])"
playwright-cli run-code --filename=script.js
playwright-cli tracing-start
playwright-cli tracing-stop
playwright-cli video-start video.webm
playwright-cli video-chapter "Chapter Title" --description="Details" --duration=2000
playwright-cli video-stop
# annotate each subsequent action (click, type, ...) with a callout naming the action and highlighting the target
playwright-cli video-show-actions --duration=600 --position=top-right
playwright-cli video-hide-actions
# launch the dashboard for
常见问题
运行它需要什么?
它使用 playwright-cli 命令行工具,因此你的电脑上必须有该工具。
它能在页面中搜索文字吗?
可以。它的 find 命令会在页面快照中搜索文字或模式,并返回带有上下文的匹配结果。
它能上传文件或拖动项目吗?
可以。命令包括上传、拖动,以及把文件或数据放到某个元素上。
详情
作者的原始描述
Automate browser interactions, test web pages and work with Playwright tests.
repo: coleam00/Archon
热度
- GitHub 星标
- 24k
- 排名
- #10123
- 许可证
- MIT
- 更新时间
- 2026/11/2
评论
- …