All skills
asyrafhussin avatar

/e2e-playwright-testing

@c03e38f

End-to-end testing with Playwright for web applications. Use when writing E2E tests, browser automation, form submission testing, or user flow testing. Triggers on "playwright", "e2e test", "browser test", "end-to-end", "form flow testing", or test files in tests/e2e/.

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/e2e-playwright-testing

This session only. Nothing lands on disk.

rulesloc-prefer-role-locators.md

≈512 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Prefer Role-Based Locators

Impact: CRITICAL (test resilience to UI changes)

Use getByRole, getByLabel, and getByText over CSS selectors or test IDs. Role-based locators mirror how users and assistive technology interact with the page, making tests resilient to refactoring.

Incorrect

// Bad: CSS selectors break when classes change
await page.locator('.btn-primary').click();
await page.locator('#submit-form').click();
await page.locator('div > form > button:nth-child(2)').click();

// Bad: data-testid couples tests to implementation
await page.locator('[data-testid="login-button"]').click();

Problems:

  • CSS classes are styling concerns, not behavior contracts
  • Selectors break on every UI redesign
  • Tests don't verify accessibility (screen readers can't find .btn-primary)
  • data-testid adds noise to production HTML

Correct

// Good: Role-based — mirrors user interaction
await page.getByRole('button', { name: 'Sign In' }).click();
await page.getByRole('tab', { name: 'Network' }).click();
await page.getByRole('heading', { name: 'Dashboard' }).toBeVisible();

// Good: Label-based — matches form field labels
await page.getByLabel('Email').fill('user@example.com');

// Good: Text-based — for non-interactive content
await expect(page.getByText('Welcome back')).toBeVisible();

// Good: Use exact when text is ambiguous
await page.getByRole('button', { name: 'Verified', exact: true });

Priority order:

  1. getByRole — buttons, tabs, headings, links, checkboxes
  2. getByLabel — form inputs with labels
  3. getByText — static content, with { exact: true } when needed
  4. locator('#id') — for inputs without labels (e.g., #password)
  5. CSS selectors — last resort for complex DOM structures

Reference: Playwright Docs — Locators

Source: SKILL.md on GitHub

No alerts16d4 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive set of best practices and patterns for writing reliable end-to-end tests using Playwright. It focuses on locator strategies, authentication reuse, form handling, and test organization. No security issues were detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at c03e38f. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 6 months ago
Other metadata
metadata
{
  "author": "Agent Skills Contributors",
  "version": "1.0.0",
  "playwrightVersion": "1.50+",
  "nodeVersion": "18+"
}

README badge

README badge for asyrafhussin/agent-skills/e2e-playwright-testing