安装步骤

安装Playwright MCP 服务器
npm install -g @executeautomation/playwright-mcp-server
配置Claude

打开Claude Desktop—>设置—>开发者

编辑claude_desktop_config.json

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@executeautomation/playwright-mcp-server"]
    }
  }
}

配置完成后重启Claude Desktop

编写API测试

GET请求
使用端点 https://api.restful-api.dev/objects 发送 GET 请求以获取所有对象并验证响应
检查状态是否为 200
确保响应主体为数组

POST请求
对 https://api.restful-api.dev/objects 执行 POST 操作

将以下数据传入响应体

{
"name": "Apple MacBook M4 Pro 16",
"data": {
"year": 2025,
"price": 6849.99,
"CPU model": "Intel Core i12",
"Hard disk size": "1 TB"
}
}

验证响应体是否包含 id 和 createdAt 值
并将生成的 id 保存到变量 id 中

可以看到仅用对话就完成了接口测试

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐