AgentSkillsCN

webapp-testing

提供基于 Playwright 的 Web 应用测试指南。当用户要求创建或运行基于浏览器的测试用例时,可选用此技能。

SKILL.md
--- frontmatter
name: webapp-testing
description: Guide for testing web applications using Playwright. Use this when asked to create or run browser-based tests.

Web Application Testing with Playwright

This skill helps you create and run browser-based tests for web applications using Playwright.

When to use this skill

Use this skill when you need to:

  • Create new Playwright tests for web applications
  • Debug failing browser tests
  • Set up test infrastructure for a new project

Creating tests

  1. Review the test template for the standard test structure
  2. Identify the user flow to test
  3. Create a new test file in the tests/ directory
  4. Use Playwright's locators to find elements (prefer role-based selectors)
  5. Add assertions to verify expected behavior

Running tests

To run tests locally:

bash
npx playwright test

To debug tests:

bash
npx playwright test --debug

Best practices

  • Use data-testid attributes for dynamic content
  • Keep tests independent and atomic
  • Use Page Object Model for complex pages
  • Take screenshots on failure