使用说明
使用MCP的剧作家自动化项目
这是一个与模型上下文协议(MCP)服务器集成的Playwright自动化项目。它为浏览器自动化和端到端测试提供了一个强大的框架。
项目结构
.
├── tests/
│ └── e2e/ # End-to-end test files
├── playwright.config.ts # Playwright configuration
├── tsconfig.json # TypeScript configuration
├── package.json # Project dependencies
├── .github/ # GitHub-related files
└── README.md # This file
入门指南
先决条件
- Node.js 18+
- npm或纱线
安装
- 安装依赖项:
npm install
- 安装Playwright浏览器:
npm run install:browsers
运行测试
运行所有测试
npm test
在头部模式下运行测试(浏览器可见)
npm run test:headed
调试测试
npm run test:debug
UI模式(交互式)
npm run test:ui
查看测试报告
npm run test:report
生成测试代码
npm run codegen
MCP集成
此项目在VS代码设置中配置了Playwright MCP服务器支持。MCP服务器通过模型上下文协议实现高级浏览器自动化功能。
配置
-
剧作家配置ts:Playwright主配置文件
- 已配置的浏览器:Chromium、Firefox、WebKit
- 默认基本URL:http://localhost:3000
- 故障截图和视频
- HTML报告
-
Tsconflict.儿子:带有路径别名的TypeScript配置
创建测试
在中创建测试文件 tests/e2e/ 和 .spec.ts 扩展名:
import { test, expect } from '@playwright/test';
test('example test', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Example/);
});
CI/CD集成
该配置支持CI/CD管道:
- CI中的串行执行
- CI中启用了重试逻辑
- 故障时的屏幕截图和视频捕捉
文档
许可证
国际学生委员会
