The Agent Skills Directory
npx skills add https://smithery.ai/skills/openai/playwright使用 playwright-cli 从终端驱动真实浏览器。优先使用捆绑的包装器脚本,这样即使 CLI 未全局安装也能工作。将此技能视为 CLI 优先的自动化。除非用户明确要求测试文件,否则不要转向 @playwright/test。
在提出命令之前,请检查 npx 是否可用(包装器依赖于此):
command -v npx >/dev/null 2>&1
如果不可用,请暂停并请用户安装 Node.js/npm(它提供 npx)。请逐字提供以下步骤:
# 验证 Node/npm 是否已安装
node --version
npm --version
# 如果缺失,安装 Node.js/npm,然后:
npm install -g @playwright/cli@latest
playwright-cli --help
一旦 npx 存在,就继续使用包装器脚本。全局安装 playwright-cli 是可选的。
export CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
export PWCLI="$CODEX_HOME/skills/playwright/scripts/playwright_cli.sh"
用户作用域下的技能安装在 $CODEX_HOME/skills 下(默认:~/.codex/skills)。
使用包装器脚本:
"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshot
如果用户偏好全局安装,这也是有效的:
npm install -g @playwright/cli@latest
playwright-cli --help
最小循环:
"$PWCLI" open https://example.com
"$PWCLI" snapshot
"$PWCLI" click e3
"$PWCLI" snapshot
在以下情况后再次快照:
引用可能会过时。当命令因引用缺失而失败时,请再次快照。
"$PWCLI" open https://example.com/form
"$PWCLI" snapshot
"$PWCLI" fill e1 "user@example.com"
"$PWCLI" fill e2 "password123"
"$PWCLI" click e3
"$PWCLI" snapshot
"$PWCLI" open https://example.com --headed
"$PWCLI" tracing-start
# ...交互...
"$PWCLI" tracing-stop
"$PWCLI" tab-new https://example.com
"$PWCLI" tab-list
"$PWCLI" tab-select 0
"$PWCLI" snapshot
包装器脚本使用 npx --package @playwright/cli playwright-cli,因此 CLI 无需全局安装即可运行:
"$PWCLI" --help
除非仓库已经标准化使用全局安装,否则优先使用包装器。
只打开你需要的:
references/cli.mdreferences/workflows.mde12 这样的元素 ID 之前,始终先快照。eval 和 run-code。eX 并说明原因;不要用 run-code 绕过引用。--headed。output/playwright/ 并避免引入新的顶级工件文件夹。每周安装数
97
来源
首次出现
2026年3月6日
安全审计
安装于
codex80
gemini-cli75
opencode74
github-copilot72
amp71
cline71
Drive a real browser from the terminal using playwright-cli. Prefer the bundled wrapper script so the CLI works even when it is not globally installed. Treat this skill as CLI-first automation. Do not pivot to @playwright/test unless the user explicitly asks for test files.
Before proposing commands, check whether npx is available (the wrapper depends on it):
command -v npx >/dev/null 2>&1
If it is not available, pause and ask the user to install Node.js/npm (which provides npx). Provide these steps verbatim:
# Verify Node/npm are installed
node --version
npm --version
# If missing, install Node.js/npm, then:
npm install -g @playwright/cli@latest
playwright-cli --help
Once npx is present, proceed with the wrapper script. A global install of is optional.
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
playwright-cliexport CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
export PWCLI="$CODEX_HOME/skills/playwright/scripts/playwright_cli.sh"
User-scoped skills install under $CODEX_HOME/skills (default: ~/.codex/skills).
Use the wrapper script:
"$PWCLI" open https://playwright.dev --headed
"$PWCLI" snapshot
"$PWCLI" click e15
"$PWCLI" type "Playwright"
"$PWCLI" press Enter
"$PWCLI" screenshot
If the user prefers a global install, this is also valid:
npm install -g @playwright/cli@latest
playwright-cli --help
Minimal loop:
"$PWCLI" open https://example.com
"$PWCLI" snapshot
"$PWCLI" click e3
"$PWCLI" snapshot
Snapshot again after:
Refs can go stale. When a command fails due to a missing ref, snapshot again.
"$PWCLI" open https://example.com/form
"$PWCLI" snapshot
"$PWCLI" fill e1 "user@example.com"
"$PWCLI" fill e2 "password123"
"$PWCLI" click e3
"$PWCLI" snapshot
"$PWCLI" open https://example.com --headed
"$PWCLI" tracing-start
# ...interactions...
"$PWCLI" tracing-stop
"$PWCLI" tab-new https://example.com
"$PWCLI" tab-list
"$PWCLI" tab-select 0
"$PWCLI" snapshot
The wrapper script uses npx --package @playwright/cli playwright-cli so the CLI can run without a global install:
"$PWCLI" --help
Prefer the wrapper unless the repository already standardizes on a global install.
Open only what you need:
references/cli.mdreferences/workflows.mde12.eval and run-code unless needed.eX and say why; do not bypass refs with run-code.--headed when a visual check will help.output/playwright/ and avoid introducing new top-level artifact folders.Weekly Installs
97
Source
First Seen
Mar 6, 2026
Security Audits
Installed on
codex80
gemini-cli75
opencode74
github-copilot72
amp71
cline71
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
40,000 周安装