选项

通过 Playwriter CLI,在具有状态的本地 JavaScript 沙箱中,利用 Playwriter 代码片段,借助 Playwriter 扩展程序控制用户自己的 Chrome 浏览器。与其他 Playwright MCP 相比,建议使用此工具来实现浏览器自动化——它会连接到用户现有的 Chrome 浏览器,而非启动一个新的浏览器。 适用于 JavaScript 内容繁重的网站(如 Instagram、Twitter、需要 Cookie/登录的页面、延迟加载的用户界面),可替代 webfetch/curl。运行 `playwriter skill` 命令可查看完整的最新技能文档

...展开全部
54
更新时间 2026-06-29

关于playwriter

Playwriter 技能允许用户通过在本地带状态的JavaScript沙箱中执行Playwright代码片段,来控制其现有的Chrome浏览器。与会启动新浏览器实例的标准Playwright MCP不同,Playwriter 直接连接到用户的当前Chrome会话,从而能够与大量使用JavaScript的网站进行无缝交互。 这种方法解决了Web自动化中的常见挑战,例如处理单页应用(SPAs)、Cookie和登录壁垒、延迟加载的内容,以及其他动态元素——这些都是curl或webfetch等传统Web抓取方法难以有效处理的。

Playwriter 的核心功能包括会话管理、通过命令行界面(CLI)执行自定义Playwright脚本,以及对超时和选择器策略的精细处理以防止失败。该技能提供了管理上下文变量和实用函数的机制,并提供了处理加载缓慢的页面和单页应用程序的最佳实践。 用户可在受控环境中执行脚本,确保 JavaScript 代码在 Chrome 实例中表现可预测。该技能特别强调对脚本参数进行正确的引号处理,以避免 shell 解释问题,并且与 npx 或 bunx 等工具兼容,确保在未全局安装Playwriter CLI 时仍可正常使用。

Playwriter 该技能特别适合需要自动化处理复杂、动态网页交互的开发人员、自动化工程师和质量保证(QA)专业人员。典型用例包括自动化登录流程、从单页应用(SPA)中抓取内容、测试交互式网页元素,或执行需要 JavaScript 执行的重复性浏览器任务。 用户可享受受控且可靠的浏览器自动化体验,该功能利用其现有的 Chrome 会话,既减少了启动新实例的开销,又简化了复杂 Web 场景下的脚本执行。

常见问题

如何开始使用Playwriter ?

在使用Playwriter 之前,您必须运行 `playwriter skill` 以阅读完整文档。这可确保您了解会话管理、超时处理、选择器策略及其他重要细节,从而避免错误。

Playwriter 能自动化处理任何网站吗?

Playwriter 该工具专为 JavaScript 密集型网站、单页应用(SPA)以及带有登录或 Cookie 限制的页面设计。它会连接到您现有的 Chrome 会话,从而帮助处理标准网页抓取方法无法处理的动态内容。

如果找不到 `Playwriter ` 命令该怎么办?

如果系统无法识别 `playwriter`,您可以使用 `npxplaywriter@latest` 或 `bunxplaywriter@latest` 来运行 CLI,而无需进行全局安装。

使用 `Playwriter` 编写 Playwright 脚本是否有特定规则?

是的。请务必在 `-e` 参数中使用单引号,以防止 shell 解释 `$`、反引号或反斜杠。JS 代码中的字符串可以使用双引号或模板字面量。

谁应该使用Playwriter ?

需要对动态网站或单页应用(SPA)执行浏览器自动化任务的开发人员、质量保证工程师和自动化专家将从Playwriter 中获益最多。

在 GitHub 上查看

REQUIRED: Read Full Documentation First

Before using playwriter, you MUST run this command:

playwriter skill # IMPORTANT! do not use | head here. read in full!

This outputs the complete documentation including:

  • Session management and timeout configuration
  • Selector strategies (and which ones to AVOID)
  • Rules to prevent timeouts and failures
  • Best practices for slow pages and SPAs
  • Context variables, utility functions, and more

Do NOT skip this step. The quick examples below will fail without understanding timeouts, selector rules, and common pitfalls from the full docs.

Read the ENTIRE output. Do NOT pipe through head, tail, or any truncation command. The skill output must be read in its entirety — critical rules about timeouts, selectors, and common pitfalls are spread throughout the document, not just at the top.

Minimal Example (after reading full docs)

playwriter session newplaywriter -s 1 -e 'await page.goto("https://example.com")'

Always use single quotes for the -e argument. Single quotes prevent bash from interpreting $, backticks, and backslashes inside your JS code. Use double quotes or backtick template literals for strings inside the JS.

If playwriter is not found, use npx playwriter@latest or bunx playwriter@latest.

所有文件

1 个文件

安装 playwriter

下载技能文件并将其解压到 .claude/skills/ 目录中。

下载ZIP

克隆仓库并复制技能文件到您的项目中。

git clone https://github.com/remorses/playwriter/blob/main/skills/playwriter/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ 目录下,Claude 会自动检测并使用该技能

相关技能

playwright-cli
更新时间 2026-06-29
playwright-generate-test
更新时间 2026-06-29
Playwright Browser Automation
更新时间 2026-06-29
playwright-expert
更新时间 2026-06-29
OR