页面对象模型测试套件

一个基于Playwright的页面对象模型测试套件,用于演示和实现网页搜索功能的自动化测试。

  • by Rahul11021993
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 Rahul11021993/Playwright-MCP

使用说明

剧作家POM示例

此工作区包含一个演示页面对象模型(POM)的小型Playwright测试套件。

添加的文件:

  • pages/base.page.ts --通用助手和导航。
  • pages/home.page.ts --主页POM(搜索)。
  • pages/searchResults.page.ts --搜索结果POM(产品检查)。
  • tests/search.spec.ts --“褪色短袖T恤”检测呈阳性。
  • tests/search-negative.spec.ts --无意义搜索的阴性测试。

运行测试(PowerShell):

npx playwright test tests/search.spec.ts -c playwright.config.ts -u
npx playwright test tests/search-negative.spec.ts -c playwright.config.ts -u

# or run all tests
npx playwright test -c playwright.config.ts -u

显示HTML报告:

npx playwright show-report

笔记:

  • POM班住在 pages/.
  • 选择器很简单,如果你扩展套件,可以集中使用。