playwright-mcp-dev

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MCP

MCP

Adding MCP Tools

添加MCP工具

  • Create a new tool in
    packages/playwright/src/mcp/browser/tools/your-tool.ts
  • Register the tool in
    packages/playwright/src/mcp/browser/tools.ts
  • Add ToolCapability in
    packages/playwright/src/mcp/config.d.ts
  • Place new tests in
    tests/mcp/mcp-<category>.spec.ts
  • packages/playwright/src/mcp/browser/tools/your-tool.ts
    中创建一个新工具
  • packages/playwright/src/mcp/browser/tools.ts
    中注册该工具
  • packages/playwright/src/mcp/config.d.ts
    中添加ToolCapability
  • 将新测试用例放在
    tests/mcp/mcp-<category>.spec.ts

Building

构建

  • Assume watch is running at all times, run lint to see type errors
  • 假设watch始终处于运行状态,运行lint检查类型错误

Testing

测试

  • Run tests as
    npm run ctest-mcp <category>
  • Do not run test --debug
  • 执行
    npm run ctest-mcp <category>
    运行测试
  • 请勿使用test --debug运行测试

CLI

CLI

Adding commands

添加命令

  • CLI commands are based on MCP tools. Implement the corresponding MCP tool as per
    Adding MCP Tools
    section above, if needed.
  • Add new CLI category for tool if needed:
    • Add Category in
      packages/playwright/src/mcp/terminal/command.ts
    • Update doc generator
      packages/playwright/src/mcp/terminal/helpGenerator.ts
  • Register command in
    packages/playwright/src/mcp/terminal/commands.ts
  • Update skill file at
    packages/playwright/src/skill/SKILL.md
    and references if necessary in
    packages/playwright/src/skill/references/
  • Place new tests in
    tests/mcp/cli-<category>.spec.ts
  • CLI命令基于MCP工具。如有需要,请按照上述“添加MCP工具”部分实现对应的MCP工具。
  • 如有需要,为工具添加新的CLI分类:
    • packages/playwright/src/mcp/terminal/command.ts
      中添加分类
    • 更新文档生成器
      packages/playwright/src/mcp/terminal/helpGenerator.ts
  • packages/playwright/src/mcp/terminal/commands.ts
    中注册命令
  • 必要时更新
    packages/playwright/src/skill/SKILL.md
    中的技能文件及其在
    packages/playwright/src/skill/references/
    中的引用
  • 将新测试用例放在
    tests/mcp/cli-<category>.spec.ts

Building

构建

  • Assume watch is running at all times, run lint to see type errors
  • 假设watch始终处于运行状态,运行lint检查类型错误

Testing

测试

  • Run tests as
    npm run ctest-mcp cli-<category>
  • Do not run test --debug
  • 执行
    npm run ctest-mcp cli-<category>
    运行测试
  • 请勿使用test --debug运行测试

Lint

Lint

  • run
    npm run flint
    to lint everything before commit
  • 提交前执行
    npm run flint
    对所有内容进行lint检查

SKILL File

SKILL文件

The skill file is located at
packages/playwright/src/skill/SKILL.md
. It contains documentation for all available CLI commands and MCP tools. Update it whenever you add new commands or tools. At any point in time you can run "npm run playwright-cli -- --help" to see the latest available commands and use them to update the skill file.
技能文件位于
packages/playwright/src/skill/SKILL.md
,包含所有可用CLI命令和MCP工具的文档。添加新命令或工具时请更新该文件。 任何时候你都可以运行“npm run playwright-cli -- --help”查看最新可用命令,并使用它们来更新技能文件。