webapp-testing

软件研发 测试与质量 2 文件 EN 原文 1 脚本

Toolkit for interacting with and testing local w

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

说明语言:英文

来源anthropicsskills ↗ 查看原文件 ↗版权归原作者,请遵循原仓库许可
安装
npx skills add https://github.com/anthropics/skills --skill webapp-testing

需要已安装 skills CLI。也可以直接从源仓库 clone。

在星云中查看 ↗
SKILL.md 原文

name: webapp-testing description: Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs. ---

Web Application Testing

This skill enables comprehensive testing and debugging of local web applications using Playwright automation.

You should use the Playwright MCP Server to undertake the work if possible. If the MCP Server is unavailable, you can run the code in a local Node.js environment with Playwright installed.

When to Use This Skill

Use this skill when you need to:

Prerequisites

Core Capabilities

1. Browser Automation

2. Verification

3. Debugging

Usage Examples

Example 1: Basic Navigation Test

// Navigate to a page and verify title
await page.goto("http://localhost:3000");
const title = await page.title();
console.log("Page title:", title);

Example 2: Form Interaction

// Fill out and submit a form
await page.fill("#username", "testuser");
await page.fill("#password", "password123");
await page.click('button[type="submit"]');
await page.waitForURL("**/dashboard");

Example 3: Screenshot Capture

// Capture a screenshot for debugging
await page.screenshot({ path: "debug.png", fullPage: true });

Guidelines

  1. Always verify the app is running - Check that the local server is accessible before running tests
  2. Use explicit waits - Wait for elements or navigation to complete before interacting
  3. Capture screenshots on failure - Take screenshots to help debug issues
  4. Clean up resources - Always close the browser when done
  5. Handle timeouts gracefully - Set reasonable timeouts for slow operations
  6. Test incrementally - Start with simple interactions before complex flows
  7. Use selectors wisely - Prefer data-testid or role-based selectors over CSS classes

Common Patterns

Pattern: Wait for Element

await page.waitForSelector("#element-id", { state: "visible" });

Pattern: Check if Element Exists

const exists = (await page.locator("#element-id").count()) > 0;

Pattern: Get Console Logs

page.on("console", (msg) => console.log("Browser log:", msg.text()));

Pattern: Handle Errors

try {
  await page.click("#button");
} catch (error) {
  await page.screenshot({ path: "error.png" });
  throw error;
}

Limitations

Helper Functions

Some helper functions are available in test-helper.js to simplify common tasks like waiting for elements, capturing screenshots, and handling errors. You can import and use these functions in your tests to improve readability and maintainability.

同类技能
apple-appstore-reviewerarize-ai-provider-integrationbacktesting-frameworksbats-testing-patternsbreakdown-testcode-review-excellencecsharp-mstestcsharp-nunit
本页内容来自开源项目 anthropics, 版权归原作者所有。
本站仅作技能索引与分享,所有 Skill 版权归其原作者所有。