Skip to content
Back to skills

Collect Selector

ASecurity

Use this skill to determine the correct data-testid selector for Playwright or end-to-end tests.

  • 666 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added February 8, 2026
testing

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill collect-selector --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collect Selector?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collect Selector
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-collect-selector/badge)](https://www.skillsdirectory.com/skills/majiayu000-collect-selector)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: collect-selector
description: Use this skill to determine the correct data-testid selector for Playwright or end-to-end tests. 
---

# Collect Selector

## Purpose
Determine the correct `data-testid` for a UI component following a strict priority order.

## Logic to collect data-testid
1. Priority 1: playwrightId
   - If component has playwrightId="some-value"
   - Use in test: [data-testid="some-value"]
   - Example: <Button playwrightId="submit-btn"> → test uses [data-testid="submit-btn"]
2. Priority 2: data-testid
   - If component has data-testid="some-value" (and no playwrightId)
   - Use in test: [data-testid="some-value"]
   - Example: <Button data-testid="submit-btn"> → test uses [data-testid="submit-btn"]
3. Priority 3: Text Content
   - If no playwrightId or data-testid exists
   - Use in test: element's visible text
   - Example: <Button>Submit Form</Button> → test uses text="Submit Form"
4. Priority 4: Auto create playwrightId
   - If nothing above exists please add playwrightId using relevant value for the component
Simple Summary:
// Component has playwrightId:
<Component playwrightId="my-element" />
// Test uses:
[data-testid="my-element"]
// Component has only data-testid:
<Component data-testid="my-element" />
// Test uses:
[data-testid="my-element"]

Key Rule: Always use [data-testid="..."] in tests, whether the component has playwrightId or data-testid!

## Output Format
Return a simple string containing the resolved `data-testid` value.

If no match is found, return: `"undefined-testid"`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.