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-strict-mode.md

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

Handle Strict Mode Violations

Impact: CRITICAL (prevents test failures from ambiguous selectors)

Playwright runs in strict mode by default — locators that match multiple elements throw an error. Handle this proactively with { exact: true }, .first(), or scoped locators.

Incorrect

// Bad: "Verified" also matches "Unverified"
await page.getByRole('button', { name: 'Verified' }).click();

// Bad: "POS Demo" appears in heading AND breadcrumb
await expect(page.getByText('POS Demo')).toBeVisible();

// Bad: "Item Type" appears in form AND summary
await expect(page.getByText('Item Type')).toBeVisible();

// Bad: "Convert" matches tab name AND submit button
await page.getByRole('button', { name: /convert/i }).click();

Problems:

  • Strict mode throws: "resolved to 2 elements"
  • Tests fail with confusing error messages
  • Different elements have the same visible text

Correct

// Good: exact match prevents substring matching
await page.getByRole('button', { name: 'Verified', exact: true }).click();

// Good: use role to disambiguate heading vs breadcrumb
await expect(page.getByRole('heading', { name: 'POS Demo' })).toBeVisible();

// Good: scope to a specific container
await expect(page.locator('.form-section').getByText('Item Type')).toBeVisible();

// Good: use specific button text
await page.getByRole('button', { name: /convert 10 sp/i }).click();

// Good: use .first() when you know the first match is correct
await page.getByText('Dashboard').first().click();

// Good: filter with parent context
await page.locator('button').filter({ hasText: 'Arif Azmi' }).first().click();

Strategies (in order of preference):

  1. { exact: true } — prevents "Verified" matching "Unverified"
  2. getByRole('heading', ...) — disambiguates heading from breadcrumb/sidebar
  3. Scoped locator — container.getByText(...) limits search area
  4. .first() — when the first match is always correct
  5. .filter({ hasText: ... }) — combine with other locators

Reference: Playwright Docs — Strict Mode

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