Skip to main content

安装

🌐 Installation

先决条件

🌐 Prerequisites

  • Node.js 20 或更新版本
  • 一个编码代理:Claude Code、GitHub Copilot 或类似工具

全球安装

🌐 Global installation

npm install -g @playwright/cli@latest
playwright-cli --help

本地安装 (npx)

🌐 Local installation (npx)

npx playwright-cli --help

安装浏览器

🌐 Installing browsers

CLI 在首次使用时会自动下载浏览器。要显式安装,请执行:

🌐 The CLI downloads a browser automatically on first use. To install explicitly:

playwright-cli install-browser               # install default (chromium)
playwright-cli install-browser firefox # install specific browser
playwright-cli install-browser --with-deps # install with system dependencies

安装选项

🌐 Install options

标志描述
--with-deps安装系统依赖(Linux)
--dry-run预览将要安装的内容
--list列出所有安装中可用的浏览器
--force即使已存在也强制重新安装
--only-shell仅安装 Chromium 无头模式
--no-shell跳过 Chromium 无头模式

安装技能

🌐 Installing skills

像 Claude Code 和 GitHub Copilot 这样的编码代理可以使用本地安装的技能来获取有关可用命令的更丰富上下文:

🌐 Coding agents like Claude Code and GitHub Copilot can use locally installed skills for richer context about available commands:

playwright-cli install --skills

无需技能操作

🌐 Skills-less operation

你也可以直接将你的代理指向 CLI,让它自行发现命令:

🌐 You can also point your agent at the CLI directly and let it discover commands on its own:

Test the "add todo" flow on https://demo.playwright.dev/todomvc using playwright-cli.
Check playwright-cli --help for available commands.

环境设置

🌐 Environment setup

配置你的编码代理以使用特定的会话:

🌐 Configure your coding agent to use a specific session:

PLAYWRIGHT_CLI_SESSION=todo-app claude .

下一步

🌐 Next steps

  • 快速开始 — 试试命令行操作
  • 快照 — 元素引用的工作原理
  • 功能 — 网络模拟、存储、测试等
  • 配置 — 无头模式,浏览器选择,配置文件