agentleFS
anhtesteranhtester/codex-testing-kit/.agents/skills/smart-locator-agent/SKILL.md

smart-locator-agent

Skill28 starsChanged 4 months agoMITView on GitHub

Skill sinh locator ổn định và dễ bảo trì cho UI automation, hỗ trợ Playwright, Selenium và Appium.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when:

    line 20
  2. Distinctive:

    Use the following priority order:

    line 42
  3. Distinctive:

    Before using a locator, ensure:

    line 121
  4. Distinctive:

    When generating locators, provide:

    line 133

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Smart Locator Agent

Purpose: Generate stable and maintainable locators for UI automation.

Applicable frameworks:

  • Playwright
  • Selenium
  • Appium

When to Use

Use this skill when:

  • Generating locators for new UI elements
  • Reviewing existing locators for stability
  • Migrating locators between frameworks

Responsibilities

The agent must:

  1. Inspect the DOM or mobile UI hierarchy (NEVER guess)
  2. Identify stable attributes
  3. Generate a reliable locator
  4. Validate locator uniqueness
  5. Provide fallback locator if primary is fragile

Locator Priority

Use the following priority order:

  1. Accessibility attributes (aria-label, role)
  2. data-testid / data-test / data-qa
  3. id
  4. name
  5. Framework semantic locator
  6. css selector
  7. xpath (last option)

Note: For detailed rules, refer to .agents/rules/locator_strategy.md.


Playwright Locators

Preferred locator methods:

  1. getByRole() — Best for semantic elements
  2. getByLabel() — Best for form fields with labels
  3. getByPlaceholder() — Best for inputs with placeholder text
  4. getByText() — Best for text content
  5. getByTestId() — Best when data-testid is available

Example:

page.getByRole("button", { name: "Submit" })
page.getByLabel("Email")
page.getByPlaceholder("Enter your password")

Note: For detailed rules, refer to .agents/rules/playwright_rules.md.


Selenium Locators

Preferred order:

  1. id
  2. data-testid
  3. name
  4. cssSelector
  5. xpath

Example:

driver.findElement(By.id("login-button"));
driver.findElement(By.cssSelector("button[data-testid='submit-btn']"));

Note: For detailed rules, refer to .agents/rules/selenium_rules.md.


Appium Locators

Preferred order:

  1. accessibility id
  2. resource-id
  3. id
  4. iOS predicate string
  5. class chain
  6. xpath

Example:

driver.findElement(AppiumBy.accessibilityId("login_button"));
driver.findElement(AppiumBy.id("com.app:id/login_button"));
driver.findElement(AppiumBy.iOSNsPredicateString("label == 'Login'"));

Note: For detailed rules, refer to .agents/rules/appium_rules.md.


Validation Rules

Before using a locator, ensure:

  • It matches exactly one element
  • The element is visible and interactable
  • It is stable across page reloads
  • It survives cosmetic DOM changes (layout, styling)
  • It does NOT use dynamic class names or positional xpath

Output Format

When generating locators, provide:

  1. Primary locator — The best, most stable option
  2. Fallback locator — Alternative if primary breaks
  3. Reasoning — Why this locator was chosen

Rules References

  • .agents/rules/locator_strategy.md — Master locator priority map
  • .agents/rules/playwright_rules.md — Playwright-specific locator rules
  • .agents/rules/selenium_rules.md — Selenium-specific locator rules
  • .agents/rules/appium_rules.md — Appium-specific locator rules

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.