selector-strategies

Teach resilient accessibility-first selectors for Playwright UI tests.

Updated Jan 31, 2026
One-click install
npx skills add https://github.com/AbhiRKeesara/test-automation-skills --skill selector-strategies
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: selector-strategies
Source: https://github.com/AbhiRKeesara/test-automation-skills/tree/main/skills/selector-strategies
Command: npx skills add https://github.com/AbhiRKeesara/test-automation-skills --skill selector-strategies

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps teams reduce flaky Playwright tests by teaching resilient, accessibility-first selectors that stay stable as the UI changes. It focuses on semantic locators over brittle CSS or XPath and encourages accessibility-minded test engineering practices.

Core Features & Use Cases

  • Accessibility-first selectors using getByRole, getByLabel, and getByPlaceholder to improve test stability and readability.
  • A clear priority hierarchy that guides testers away from brittle selectors and towards robust options.
  • Practical scenarios including form testing, navigation, dynamic content, and migration between testing frameworks.

Quick Start

  • Use getByRole for interactive elements like buttons and links.
  • Prefer getByLabel for inputs with visible labels; fall back to getByPlaceholder when labels are absent.
  • Use getByText cautiously for static, unique content; if not reliable, use getByTestId as a last resort.
  • Examples: page.getByRole('button', { name: 'Submit' }).click(); page.getByLabel('Email').fill('[email protected]'); page.getByPlaceholder('Enter your email').fill('[email protected]');

Frequently Asked Questions about selector-strategies

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky Playwright tests using resilient selectors?

Fix flaky Playwright tests by replacing brittle CSS or XPath locators with resilient, accessibility-first selectors like getByRole, getByLabel, and getByPlaceholder to ensure UI test stability as the UI changes.

What is the best way to locate dynamic elements in Playwright automation?

The best way to locate dynamic elements in Playwright is using semantic locators such as getByRole for interactive elements and getByLabel for form inputs to ensure accessible and stable test interactions.

When should I use getByTestId instead of getByRole in Playwright?

Use getByTestId as a last resort in Playwright when getByRole, getByLabel, or getByText are not reliable for identifying static or unique content. Prefer getByRole for interactive elements like buttons and links.

Can I use getByPlaceholder for form testing when labels are absent?

Yes, you can use getByPlaceholder for Playwright form testing when visible labels are absent, falling back to this approach to fill inputs like email addresses where getByLabel is not applicable.

Why does relying on CSS selectors break my test automation framework?

Relying on CSS selectors breaks test automation because they are brittle and prone to failure during UI changes. Accessibility-first locators like getByRole and getByLabel maintain test stability during dynamic page updates.