🚀 一个基于 Playwright 和 TypeScript 构建的强大数据驱动测试自动化框架,利用 @executeautomation/playwright-mcp-server 增强了测试录制和回放功能。采用页面对象模型设计模式,实现可扩展和易于维护的自动化测试。
tests/
├── data/ # 测试数据层
│ ├── interfaces/
│ │ └── TestData.ts # 数据类型定义
│ ├── TestDataHelper.ts # 数据管理辅助类
│ └── testData.ts # 测试场景数据
├── pages/ # 页面对象
│ ├── BasePage.ts # 包含通用功能的基础页面
│ ├── LoginPage.ts # 登录页面对象
│ └── RegistrationPage.ts # 注册页面对象
└── specs/ # 测试规范
└── registration.spec.ts # 测试用例
框架使用结构化的方法来管理测试数据:
interface TestScenario {
name: string;
login: LoginData;
registration: RegistrationData;
}
当前测试场景:
git clone <repository-url>
cd playwrightMCP_Demo
npm install
npx playwright install
运行所有测试:
npx playwright test
运行特定测试文件:
npx playwright test tests/specs/registration.spec.ts
在有头模式下运行测试:
npx playwright test --headed
tests/data/testData.ts 中添加新的测试数据:{
name: '您的场景名称',
login: {
email: 'your.email@test.com'
},
registration: {
firstName: 'First',
lastName: 'Last',
address: 'Address',
email: 'email@test.com',
phone: '1234567890',
gender: 'Male' | 'Female',
country: '国家名称'
}
}
如有任何问题或问题,请在仓库中创建一个新的问题。