testing-e2e

alexei-led's avatarfrom alexei-led

E2E testing with Playwright MCP for browser automation, test generation, and UI testing. Use when discussing E2E tests, Playwright, browser testing, UI automation, visual testing, or accessibility testing. Supports TypeScript tests and Go/HTMX web applications.

⭐8stars🔀1forks📁View on GitHub🕐Updated Jan 3, 2026

When & Why to Use This Skill

This Claude skill empowers developers and QA engineers to perform comprehensive end-to-end (E2E) testing and browser automation using Playwright. It facilitates automated UI testing, test script generation, and accessibility audits, specifically optimized for TypeScript and Go/HTMX web applications to ensure robust software quality and seamless user experiences.

Use Cases

  • Automating regression tests for web applications to ensure new deployments do not break existing features.
  • Generating Playwright test scripts automatically from a target URL to accelerate the testing lifecycle.
  • Performing accessibility testing and visual verification using browser snapshots and DOM tree analysis.
  • Debugging complex UI interactions in HTMX-based applications by monitoring partial page updates and network requests.
  • Recording browser sessions to create reproducible bug reports and automated test cases.
nametesting-e2e
descriptionE2E testing with Playwright MCP for browser automation, test generation, and UI testing. Use when discussing E2E tests, Playwright, browser testing, UI automation, visual testing, or accessibility testing. Supports TypeScript tests and Go/HTMX web applications.
user-invocablefalse
contextfork
agentplaywright-tester

E2E Testing with Playwright

Use Playwright MCP tools for browser automation and E2E testing.

Quick Start

/test:e2e run      # Run existing tests
/test:e2e record   # Record browser session
/test:e2e generate # Generate test from URL

Spawn Agent

Task(subagent_type="playwright-tester", prompt="<task>")

Key Tools

Tool Purpose
browser_navigate Go to URL
browser_snapshot Get accessibility tree
browser_click Click elements
browser_type Type text
browser_fill_form Fill form fields
browser_generate_locator Get best locator
browser_verify_text Assert text content

Supported Stacks

  • TypeScript: Playwright Test with Page Objects
  • Go/HTMX: Test HTMX interactions, form submissions, partial updates

HTMX Testing Tips

  • Use browser_snapshot to verify DOM updates after HTMX swaps
  • Test hx-trigger, hx-swap, hx-target behaviors
  • Verify HX-* response headers in network requests
  • Assert partial page updates without full reload

Error Scenarios & Handling

Element Not Found

// BAD: Immediate failure
await page.click("#submit-btn");

// GOOD: Wait with timeout + fallback
const btn = page.locator("#submit-btn");
if ((await btn.count()) === 0) {
  // Try alternative selector
  await page.click('button[type="submit"]');
} else {
  await btn.click();
}

Recovery strategies:

  1. Use browser_snapshot to inspect current DOM state
  2. Try alternative locators (text, role, data-testid)
  3. Check if element is in iframe/shadow DOM
  4. Verify page loaded correctly (check URL, title)

Timeout Errors

Error Cause Solution
Navigation timeout Slow page load Increase timeout, check network
Action timeout Element not interactable Wait for visibility/enabled state
Expect timeout Assertion failed Verify DOM state with snapshot
// Configure timeouts
test.setTimeout(60000); // Test timeout
page.setDefaultTimeout(30000); // Action timeout

// Or per-action
await page.click("#btn", { timeout: 10000 });

Network Issues

// Wait for network idle
await page.waitForLoadState("networkidle");

// Mock failing endpoints
await page.route("**/api/**", (route) => {
  route.fulfill({ status: 500, body: "Server Error" });
});

Flaky Test Patterns

Avoid:

  • Fixed page.waitForTimeout(1000) delays
  • Brittle selectors like .btn-23
  • Tests depending on animation timing

Prefer:

  • waitForSelector, waitForLoadState
  • Role/text-based selectors: getByRole('button', { name: 'Submit' })
  • Retry patterns for known flaky operations

Debugging Failed Tests

  1. Get snapshot: browser_snapshot shows accessibility tree
  2. Screenshot: Capture current visual state
  3. Console logs: Check browser console for JS errors
  4. Network tab: Verify API calls succeeded
  5. Trace: Enable Playwright trace for post-mortem
# Run with trace
npx playwright test --trace on

# View trace
npx playwright show-trace trace.zip