{"data":{"slug":"discovered-66f16c7b3134b9c0a6f800c883edaadc353b29e0f9bc1394","title":"Playwright Expert","summary":"Write end-to-end tests with Playwright using role-based selectors, auto-waiting, and the Page Object Model. Receive test scripts, page objects, configuration recommendations, and integration support for CI\/CD pipelines.","url":"https:\/\/skillshunter.net\/skills\/discovered-66f16c7b3134b9c0a6f800c883edaadc353b29e0f9bc1394","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/discovered-66f16c7b3134b9c0a6f800c883edaadc353b29e0f9bc1394","markdown_url":"https:\/\/skillshunter.net\/skills\/discovered-66f16c7b3134b9c0a6f800c883edaadc353b29e0f9bc1394.md","download_url":"https:\/\/skillshunter.net\/skills\/discovered-66f16c7b3134b9c0a6f800c883edaadc353b29e0f9bc1394\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure Playwright is installed and configured with proper settings before running tests. Use role-based selectors and avoid CSS class selectors for better maintainability. Enable traces and screenshots for debugging flaky tests.","instructions":"---\nname: playwright-expert\ndescription: \"Use when writing E2E tests with Playwright, setting up test infrastructure, or debugging flaky browser tests. Invoke to write test scripts, create page objects, configure test fixtures, set up reporters, add CI integration, implement API mocking, or perform visual regression testing. Trigger terms: Playwright, E2E test, end-to-end, browser testing, automation, UI testing, visual testing, Page Object Model, test flakiness.\"\nlicense: MIT\nmetadata:\n  author: https:\/\/github.com\/Jeffallan\n  company: https:\/\/synergetic.solutions\n  version: \"1.1.0\"\n  domain: quality\n  triggers: Playwright, E2E test, end-to-end, browser testing, automation, UI testing, visual testing\n  role: specialist\n  scope: testing\n  output-format: code\n  related-skills: test-master, react-expert, devops-engineer\n---\n\n# Playwright Expert\n\nE2E testing specialist with deep expertise in Playwright for robust, maintainable browser automation.\n\n## Core Workflow\n\n1. **Analyze requirements** - Identify user flows to test\n2. **Setup** - Configure Playwright with proper settings\n3. **Write tests** - Use POM pattern, proper selectors, auto-waiting\n4. **Debug** - Run test \u2192 check trace \u2192 identify issue \u2192 fix \u2192 verify fix\n5. **Integrate** - Add to CI\/CD pipeline\n\n## Reference Guide\n\nLoad detailed guidance based on context:\n\n| Topic | Reference | Load When |\n|-------|-----------|-----------|\n| Selectors | `references\/selectors-locators.md` | Writing selectors, locator priority |\n| Page Objects | `references\/page-object-model.md` | POM patterns, fixtures |\n| API Mocking | `references\/api-mocking.md` | Route interception, mocking |\n| Configuration | `references\/configuration.md` | playwright.config.ts setup |\n| Debugging | `references\/debugging-flaky.md` | Flaky tests, trace viewer |\n\n## Constraints\n\n### MUST DO\n- Use role-based selectors when possible\n- Leverage auto-waiting (don't add arbitrary timeouts)\n- Keep tests independent (no shared state)\n- Use Page Object Model for maintainability\n- Enable traces\/screenshots for debugging\n- Run tests in parallel\n\n### MUST NOT DO\n- Use `waitForTimeout()` (use proper waits)\n- Rely on CSS class selectors (brittle)\n- Share state between tests\n- Ignore flaky tests\n- Use `first()`, `nth()` without good reason\n\n## Code Examples\n\n### Selector: Role-based (correct) vs CSS class (brittle)\n\n```typescript\n\/\/ \u2705 Role-based selector \u2014 resilient to styling changes\nawait page.getByRole('button', { name: 'Submit' }).click();\nawait page.getByLabel('Email address').fill('user@example.com');\n\n\/\/ \u274c CSS class selector \u2014 breaks on refactor\nawait page.locator('.btn-primary.submit-btn').click();\nawait page.locator('.email-input').fill('user@example.com');\n```\n\n### Page Object Model + Test File\n\n```typescript\n\/\/ pages\/LoginPage.ts\nimport { type Page, type Locator } from '@playwright\/test';\n\nexport class LoginPage {\n  readonly page: Page;\n  readonly emailInput: Locator;\n  readonly passwordInput: Locator;\n  readonly submitButton: Locator;\n  readonly errorMessage: Locator;\n\n  constructor(page: Page) {\n    this.page = page;\n    this.emailInput = page.getByLabel('Email address');\n    this.passwordInput = page.getByLabel('Password');\n    this.submitButton = page.getByRole('button', { name: 'Sign in' });\n    this.errorMessage = page.getByRole('alert');\n  }\n\n  async goto() {\n    await this.page.goto('\/login');\n  }\n\n  async login(email: string, password: string) {\n    await this.emailInput.fill(email);\n    await this.passwordInput.fill(password);\n    await this.submitButton.click();\n  }\n}\n```\n\n```typescript\n\/\/ tests\/login.spec.ts\nimport { test, expect } from '@playwright\/test';\nimport { LoginPage } from '..\/pages\/LoginPage';\n\ntest.describe('Login', () => {\n  let loginPage: LoginPage;\n\n  test.beforeEach(async ({ page }) => {\n    loginPage = new LoginPage(page);\n    await loginPage.goto();\n  });\n\n  test('successful login redirects to dashboard', async ({ page }) => {\n    await loginPage.login('user@example.com', '<test-password>');\n    await expect(page).toHaveURL('\/dashboard');\n  });\n\n  test('invalid credentials shows error', async () => {\n    await loginPage.login('user@example.com', '<wrong-password>');\n    await expect(loginPage.errorMessage).toBeVisible();\n    await expect(loginPage.errorMessage).toContainText('Invalid credentials');\n  });\n});\n```\n\n### Debugging Workflow for Flaky Tests\n\n```typescript\n\/\/ 1. Run failing test with trace enabled\n\/\/ playwright.config.ts\nuse: {\n  trace: 'on-first-retry',\n  screenshot: 'only-on-failure',\n}\n\n\/\/ 2. Re-run with retries to capture trace\n\/\/ npx playwright test --retries=2\n\n\/\/ 3. Open trace viewer to inspect timeline\n\/\/ npx playwright show-trace test-results\/...\/trace.zip\n\n\/\/ 4. Common fix \u2014 replace arbitrary timeout with proper wait\n\/\/ \u274c Flaky\nawait page.waitForTimeout(2000);\nawait page.getByRole('button', { name: 'Save' }).click();\n\n\/\/ \u2705 Reliable \u2014 waits for element state\nawait page.getByRole('button', { name: 'Save' }).waitFor({ state: 'visible' });\nawait page.getByRole('button', { name: 'Save' }).click();\n\n\/\/ 5. Verify fix \u2014 run test 10x to confirm stability\n\/\/ npx playwright test --repeat-each=10\n```\n\n## Output Templates\n\nWhen implementing Playwright tests, provide:\n1. Page Object classes\n2. Test files with proper assertions\n3. Fixture setup if needed\n4. Configuration recommendations\n\n## Knowledge Reference\n\nPlaywright, Page Object Model, auto-waiting, locators, fixtures, API mocking, trace viewer, visual comparisons, parallel execution, CI\/CD integration\n\nMaintained by [@jeffallan](https:\/\/github.com\/jeffallan), Principal Consultant at [Synergetic Solutions](https:\/\/synergetic.solutions)\n\n[Documentation](https:\/\/jeffallan.github.io\/claude-skills\/skills\/quality\/playwright-expert\/)\n","use_cases":["Write E2E tests with Playwright","Set up test infrastructure","Debug flaky browser tests","Create page objects for maintainability","Configure test fixtures and reporters","Add CI\/CD integration for test automation"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/Jeffallan\/claude-skills\/blob\/a8be463010e2ca23afe00ea00773aea7128e8971\/plugin\/skills\/playwright-expert\/SKILL.md","source_commit":"a8be463010e2ca23afe00ea00773aea7128e8971","license":null,"version":null,"listing_approved_at":"2026-11-29","created_at":"2026-11-28T18:47:40.000000Z","updated_at":"2026-11-29T10:53:27.000000Z","seo_title":"Playwright Expert - E2E Testing with Playwright","seo_description":"Write reliable end-to-end tests with Playwright using best practices like role-based selectors, auto-waiting, and the Page Object Model. Get test scripts, page objects,CI","seo_keywords":["Playwright","E2E test","end-to-end testing","browser testing","automation","UI testing","visual regression testing","Page Object Model"]}}