前期准备:安装wsl和nodejs
安装Playwright包
- wsl内全局安装Playwright包(只需执行一次)
npm install -g playwright
- 安装浏览器
npx playwright install
或指定浏览器
npx playwright install chromium firefox chrome
- 检查全局安装的Playwright版本
playwright --version
- 尝试运行一个简单页面(测试浏览器)
npx playwright open 163.com
配置 playwright MCP
针对特定项目
# 进入项目目录
cd to/path/demo# 添加mcp(运行结果是修改 ~/claude.json ,添加mcpServers一节内容)
claude mcp add playwright npx @playwright/mcp@latest# 启动
claude
测试提示词:使用 playwright mcp 打开 163.com