剧作家mcp poc
目的:使用Playwright和Playwright MCP服务器对Black&Veatch主页进行端到端功能烟雾测试,该服务器由页面对象模型(POM)、夹具和实用程序构成。
项目结构
playwright.config.ts:全局Playwright配置(测试目录、项目、报告器)。tests/:测试规范。
- bv-homepage.spec.ts:完整的主页烟雾套件,涵盖场景1-5 notes/prompt.txt. - example.spec.ts:默认Playwright示例测试。
pages/:页面对象模型类。
- homePage.ts:主页操作、导航、搜索和功能卡交互。 - contentPages.ts:关于我们、我们为谁服务、我们做什么、可持续发展、项目、职业、联系方式、新闻编辑室、地点和搜索结果的打字页面类。
fixtures/
- bvFixtures.ts:定制剧作家 test 可重复使用 homePage 夹具和 BASE_URL.
utils/
- logger.ts:跨页面和测试使用的简单记录器,用于记录主要操作和断言。
notes/
- prompt.txt:此概念验证的原始分步说明。
安装依赖项
从项目根:
npm install这将安装Playwright Test及其TypeScript类型(浏览器应该已经从 npm init playwright@latest,但你可以重新运行 npx playwright install 如果需要)。
运行测试(无头)
从项目根:
npx playwright test或者通过npm脚本:
npm test运行测试(带标题)
npx playwright test --headed或者运行一个测试文件:
npx playwright test tests/bv-homepage.spec.ts --headed生成Playwright HTML报告
运行测试,然后打开报告:
npx playwright test
npx playwright show-report报告目录(playwright-report)已通过排除 .gitignore.
