Agent skill

Selectors

by idavidov13 in idavidov13/agentic-playwright

Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector…

MITAuto-check passedTesting & QA

Install Selectors

skills CLI
$ npx skills add idavidov13/agentic-playwright --skill selectors -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install idavidov13/agentic-playwright selectors --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/idavidov13/agentic-playwright.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/selectors .claude/skills/selectors && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
selectors
GitHub stars
223
Token cost
~2.7k tokens
SKILL.md length
1,124 words
Files
4 (incl. references)
Skills in repo
13
Repo updated
First seen
Licence
MIT

At a glance

Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector…

  • Works in 4 steps: Open and authenticate → Explore like a user → Plan test coverage → …
  • Creating page objects
  • SKILL.md covers Critical, Instructions, Priority Order (Mandatory) and Correct Examples, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Selectors is an agent skill from idavidov13/agentic-playwright. Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector rules for Playwright page objects. Use when creating page objects, writing or updating locators, generating UI tests, or deciding which selector strategy to use for a given element. Enforces mandatory live-app exploration via playwright-cli before any selector generation. For the page-object class structure, JSDoc rules…

Its SKILL.md is about 2.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/examples.md`, `references/feedback-selectors-example.md` and `references/troubleshooting.md`).

It sits in Testing & QA, covering Browser testing and Technical documentation. It works with Playwright. The repository describes itself as: Production-grade Playwright + TypeScript Scaffold for Agentic Testing. Harness for all major AI coding agents baked in. The licence is MIT.

When your agent uses it

  • Creating page objects
  • Updating locators
  • Generating UI tests
  • Deciding which selector strategy to use for a given element

Example prompts

  • “/selectors”

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Open and authenticate
  2. Explore like a user
  3. Plan test coverage
  4. Generate selectors

What it can do on your machine

Read from SKILL.md and the folder at commit f6cbf35. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are bash and typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Selectors loads about 2.7k tokens when it runs, and up to ~4.6k if it reads all its reference files. Until then it costs about 177 tokens; SKILL.md has 1,124 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~177
When it runs · the whole SKILL.md, loaded when a task matches
~2.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from idavidov13/agentic-playwright at commit f6cbf35, republished under its MIT licence (© idavidov13). 1,124 words, ~2,748 tokens.

Download SKILL.mdSave it as .claude/skills/selectors/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
selectors
description
Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector rules for Playwright page objects. Use when creating page objects, writing or updating locators, generating UI tests, or deciding which selector strategy to use for a given element. Enforces mandatory live-app exploration via playwright-cli before any selector generation. For the page-object class structure, JSDoc rules, and fixture registration see the page-objects skill; for the exploration tool itself see the playwright-cli skill; for UI message strings used inside getByText see the enums skill.
author
Ivan Davidov

Selector Strategy

Critical

  • Selector priority order is mandatory: getByRole > getByLabel > getByPlaceholder > getByText > getByTestId. Move to the next option only when the previous one is not feasible.
  • NEVER use XPath (page.locator('//...') or 'xpath=...').
  • NEVER use CSS class or ID selectors as the primary strategy (page.locator('.btn-primary'), page.locator('#submit')). Acceptable only as an absolute last resort after ruling out every semantic option.
  • Exploration with playwright-cli is mandatory before writing any selectors. No guessing from wireframes, docs, or screenshots. Read the playwright-cli skill for the commands.
  • If the app cannot be reached or auth fails, stop and notify the human — never ship placeholder locators with guessed names.
  • String values inside getByText(...) come from enums/{area}/* (e.g. Messages.LOGIN_ERROR). Never hardcode repeated UI strings. See the enums skill.
  • Every page object covering forms or CRUD must include feedback / validation message selectors — success, error, field validation, toast, loading, empty state as applicable. A page object without them is incomplete.
  • Locators are get accessors returning Locator — this is a style/readability convention in the scaffold. Playwright's Locator is lazy, so get and a readonly field set in the constructor behave identically at runtime.

Instructions

Phase 1: Open and authenticate

Never generate selectors from assumptions or documentation alone. Before writing any locators or page objects, explore the live application by running playwright-cli in the terminal (read the playwright-cli skill). Do not use IDE browser MCP, Cursor browser tools, or any substitute — orchestrator rule: No Substitute UI Exploration. If playwright-cli cannot run, stop and notify the human.

bash
playwright-cli open <APP_URL>
playwright-cli snapshot

If the page fails to load or requires authentication:

  1. Stop immediately — do not guess selectors or proceed with placeholder locators.
  2. Notify the human with the exact issue: "The application at <URL> returned [error/login page/blank screen]. I need [credentials / a different URL / instructions to set up auth state] before I can proceed."
  3. Wait for the human to provide remediation (login credentials, storage state file, environment variables, or manual login instructions).
  4. After remediation, re-open and verify the page loads correctly before continuing.
Phase 2: Explore like a user

Navigate through the feature under test the way a real user would. At each page/state, take a snapshot and observe:

  • Forms — input fields, labels, dropdowns, checkboxes, radio buttons.
  • Buttons and CTAs — submit, cancel, delete, edit, create actions.
  • Navigation — links, menus, breadcrumbs, tabs.
  • Feedback elements — success banners, error messages, validation errors on fields, toast notifications, loading spinners.
  • Dynamic content — content that appears after actions (modals, expanded sections, new rows in tables).
bash
playwright-cli snapshot
playwright-cli click <ref>
playwright-cli snapshot

Trigger CRUD operations where possible to discover the actual validation messages and success/error feedback the application displays. Capture the exact text rendered — this will go into enums via the enums skill.

Phase 3: Plan test coverage

Based on what was discovered, draft a test plan covering the critical paths. The plan should identify:

  1. Happy paths — the primary successful flows (create, read, update, delete).
  2. Validation paths — what happens when required fields are empty, invalid data is submitted, etc.
  3. Error paths — server errors, permission denied, resource not found.
  4. Edge cases — boundary inputs, concurrent operations, empty states.

If feature documentation exists (user stories, acceptance criteria, design specs), cross-reference it with the discovered UI to ensure coverage is complete.

No human approval is needed for this plan — proceed directly to generating selectors and page objects.

Phase 4: Generate selectors

Now that the real UI is understood, generate selectors using the Priority Order below. Pay special attention to feedback / validation message selectors — these are the most commonly missed.

Priority Order (Mandatory)

Use semantic locators in this order. Move to the next option ONLY when the previous one is not feasible:

  1. getByRole() — Accessibility-based. Always the first choice for buttons, links, headings, textboxes, checkboxes, etc.
  2. getByLabel() — For form inputs that have associated <label> elements.
  3. getByPlaceholder() — For inputs with placeholder text when no label exists.
  4. getByText() — For static text content, messages, or non-interactive elements.
  5. getByTestId() — Fallback when none of the above produce a reliable locator.

Correct Examples

typescript
// 1. getByRole -- buttons, links, headings, navigation
page.getByRole('button', { name: 'Submit' });
page.getByRole('link', { name: 'Dashboard' });
page.getByRole('heading', { name: 'Welcome' });
page.getByRole('navigation');
page.getByRole('textbox', { name: 'Email' });
page.getByRole('checkbox', { name: 'Remember me' });

// 2. getByLabel -- form fields with labels
page.getByLabel('Email');
page.getByLabel('Password');

// 3. getByPlaceholder -- inputs without labels
page.getByPlaceholder('Search...');

// 4. getByText -- static content
page.getByText('Login successful');
page.getByText(Messages.LOGIN_ERROR); // prefer enums for repeated strings

// 5. getByTestId -- last resort
page.getByTestId('user-avatar');

Forbidden (NEVER Use)

  • XPath selectors — brittle, unreadable, not accessible.

    typescript
    // FORBIDDEN
    page.locator('//div[@id="test"]');
    page.locator('xpath=//button[text()="Submit"]');
  • CSS selectors for primary strategy — acceptable only as a page.locator() last resort, never as the default approach.

    typescript
    // AVOID unless absolutely necessary
    page.locator('.btn-primary');
    page.locator('#submit-button');
Show full SKILL.md (435 more words)Show less

Choosing Between Similar Locators

  • If the element has a role (button, link, heading, etc.), always prefer getByRole().
  • If the element is a form input with a label, prefer getByLabel() over getByRole('textbox').
  • If identifying by exact text risks matching multiple elements, add { exact: true } or use a more specific role.
  • If a parent container contains several similar elements, scope the search: page.getByRole('form').getByRole('button', { name: 'Save' }).
  • Use enums for repeated string values (error messages, labels) rather than hardcoding strings — see the enums skill.

Feedback & Validation Message Selectors

Every page object that covers a form or CRUD operation must include selectors for the feedback the application shows after those operations. These are the most commonly missed selectors and the most important for assertion coverage.

What to Capture
Feedback TypeWhen It AppearsSelector Strategy
Success messageAfter successful create/update/deletegetByText(Messages.CREATED_SUCCESS) or getByRole('alert')
Error messageAfter failed submission or server errorgetByText(Messages.SAVE_FAILED) or getByRole('alert')
Field validationOn blur or on submit with invalid inputgetByText('Email is required') scoped to the form/field container
Toast / notificationTemporary banner after any operationgetByRole('status') or getByText() on the toast content
Loading stateDuring async operationsgetByRole('progressbar') or getByText('Loading...')
Empty stateWhen a list/table has no datagetByText('No items found') or getByRole('heading') in empty state

The Messages.* values shown above are illustrative placeholders. Use the real enum members from your scaffold's enums/{area}/*.ts (e.g. Messages.LOGIN_SUCCESS, Messages.LOGIN_ERROR, Messages.REQUIRED_FIELD). Capture the exact rendered text with playwright-cli first and encode it via the enums skill.

For a full worked code example (page object class with form + feedback locators + action method, plus how the test asserts on it), see references/feedback-selectors-example.md.

Forbidden: Page objects without feedback selectors

If a page object covers a form or CRUD operation but has no selectors for success/error/validation messages, the page object is incomplete. Every form submission or data mutation should have at least a success and error message selector so tests can verify the outcome.

See Also

  • page-objects skill — POM class structure (constructor, three locator sections, action methods), JSDoc rules, fixture registration, component composition.
  • playwright-cli skill — the terminal-only live-app exploration tool used in Phase 1 and Phase 2.
  • enums skill — where Messages.*, ApiEndpoints.*, and other app-defined strings live; live-text verification workflow.
  • common-tasks skill — prompt templates for "Add a New Page Object (With / Without Exploration)" that chain into this skill.
  • debugging skill — strict-mode violations (locator matched multiple), "element not found" / "not attached", and other locator-driven test failures.
  • references/examples.md — three worked examples (new login page, adding feedback selectors, getByRole vs getByLabel decision).
  • references/feedback-selectors-example.md — full page-object code pattern with feedback locators and assertion usage.
  • references/troubleshooting.md — common selector pitfalls (multi-match, XPath temptation, stale locators, missing feedback) and their fixes.

© idavidov13, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in .claude/skills/selectors of idavidov13/agentic-playwright.

  • SKILL.md
  • references/examples.md
  • references/feedback-selectors-example.md
  • references/troubleshooting.md

Open the folder on GitHubat commit f6cbf35

Compare with similar skills

Selectors next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Selectors compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Selectors this skillidavidov13/agentic-playwright223—~2.7kAutomated safety check: PassMIT
Python Testingmacalbert/envilder138—~3.1kAutomated safety check: PassMIT
Web Application Testinganthropics/skills180k51 repos~966Automated safety check: PassApache-2.0
Playwright CLIsanity-io/sanity6.4k18 repos~1.9kAutomated safety check: PassMIT
playwright-cli Browser Automationgithub/gh-aw5.4k24 repos~2.8kAutomated safety check: PassMIT
Write and Verify Playwright Testsappsmithorg/appsmith41k—~2.9kAutomated safety check: NotesApache-2.0

Similar skills

  • Python Testing

    macalbert/envilder

    Mandatory testing conventions including AAA pattern, test naming, assertions, and mocks.

    138 GitHub stars~3.1k tokensUpdated 2 days ago
    Testing & QAAuto-check passed
  • Web Application Testing

    anthropics/skills

    Official

    Tests local web applications with Python Playwright scripts, checking frontend behavior, capturing screenshots and reading browser console logs.

    180k GitHub starsUsed in 51 repos~966 tokens
    Testing & QAAuto-check passed
  • Playwright CLI

    sanity-io/sanity

    Official

    Automates browser interactions for web testing, form filling, screenshots, and data extraction.

    6.4k GitHub starsUsed in 18 repos~1.9k tokens
    Testing & QAAuto-check passed
  • Official

    Drives a real browser from the command line with playwright-cli to open pages, interact, mock requests, save state and work with Playwright tests.

    5.4k GitHub starsUsed in 24 repos~2.8k tokens
    Testing & QAAuto-check passed
  • Writes a Playwright end-to-end test from a prompt, runs it against a live Appsmith deployment and retries with fixes up to three times until it passes.

    41k GitHub stars~2.9k tokensUpdated today
    Testing & QAAuto-check: notes
  • Guides changes and reviews of the Cucumber and Playwright end-to-end suite under `e2e/`: feature files, step definitions, support code, tags, locators and assertions.

    158k GitHub stars~682 tokensUpdated today
    Testing & QAAuto-check passed

More from idavidov13/agentic-playwright

All 13 skills in this repo
  • AI Native Workflow

    idavidov13/agentic-playwright

    Sole entry-point router for AI-assisted work on this Playwright scaffold — owns the 8-phase main workflow (classify → route → explore → plan+confidence → human gate → apply → verify → report), the…

    223 GitHub stars~3.5k tokensUpdated 6 days ago
    Auto-check passed
  • Common Tasks

    idavidov13/agentic-playwright

    Copy-paste AI prompt templates for common Playwright scaffold development tasks — adding page objects, functional/E2E/API tests, Zod schemas, factories, fixtures, and components.

    223 GitHub stars~2.5k tokensUpdated 6 days ago
    Auto-check passed
  • Data Strategy

    idavidov13/agentic-playwright

    Test data strategy for the Playwright scaffold — Faker + Zod factories for dynamic happy-path data, static TS files (.ts with as const exports — never .json) for domain-specific curated invalid…

    223 GitHub stars~3.4k tokensUpdated 6 days ago
    Auto-check passed
  • Page Objects

    idavidov13/agentic-playwright

    Page Object Model pattern for the Playwright scaffold — class structure, get-accessor locator pattern, action-method conventions, component composition, registration via the page-object fixture, and…

    223 GitHub stars~3.6k tokensUpdated 6 days ago
    Auto-check passed
  • Test Standards

    idavidov13/agentic-playwright

    Spec file conventions for the Playwright scaffold — imports from test-options.ts, test file structure (describe / beforeEach / test / test.step), single-tag rule, functional vs E2E vs API vs setup…

    223 GitHub stars~3.9k tokensUpdated 6 days ago
    Auto-check passed
  • Type Safety

    idavidov13/agentic-playwright

    TypeScript type safety conventions for the Playwright scaffold — the "no any" rule, Zod 4 schema patterns (z.strictObject, top-level validators like z.uuid / z.email / z.url / z.int / z.enum)…

    223 GitHub stars~3.5k tokensUpdated 6 days ago
    Auto-check passed

Works with

Categories

Questions about Selectors

What does Selectors do?

Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector…. Selectors is an agent skill from idavidov13/agentic-playwright. Selector strategy, exploration-first workflow, locator priority order (getByRole then getByLabel then getByPlaceholder then getByText then getByTestId), and feedback/validation-message selector rules for Playwright page objects.

When should I use Selectors?

Selectors fits situations like: creating page objects; updating locators; generating UI tests; deciding which selector strategy to use for a given element.

How do I install Selectors in Claude Code?

Run `npx skills add idavidov13/agentic-playwright --skill selectors -a claude-code`. Or copy the skill folder (.claude/skills/selectors in idavidov13/agentic-playwright) into .claude/skills/selectors in your project. Claude Code loads it when a task matches its description.

How do I install Selectors in Codex?

Run `npx skills add idavidov13/agentic-playwright --skill selectors -a codex`. Or copy the skill folder (.claude/skills/selectors in idavidov13/agentic-playwright) into .agents/skills/selectors in your project. Codex loads it when a task matches its description.

Can I use Selectors in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add idavidov13/agentic-playwright --skill selectors -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/selectors, .gemini/skills/selectors, .github/skills/selectors and .opencode/skills/selectors in your project.

What does Selectors need to run?

SKILL.md names no scripts, command-line tools or credentials: Selectors is instructions for the agent only.

Does Selectors access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Selectors safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Selectors use?

Selectors is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Selectors use?

About 2.7k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.8k tokens, read only when the agent opens those files.

What are the alternatives to Selectors?

Skills that share tags, products or a category with Selectors: Python Testing (macalbert/envilder, 138 stars), Web Application Testing (anthropics/skills, 180k stars), Playwright CLI (sanity-io/sanity, 6.4k stars) and playwright-cli Browser Automation (github/gh-aw, 5.4k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Selectors?

idavidov13 (a GitHub user) maintains it in idavidov13/agentic-playwright, which has 223 GitHub stars. The repository holds 13 skills in this directory. The repository was last updated on October 1, 2026.

Source: idavidov13/agentic-playwright on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.