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.
In this repository26 other files it gives its agents.
- AGENTS.mdAGENTS.md
- analyze-flaky-testsSkill
- analyze-requirement-documentSkill
- fetch-jira-requirementsSkill
- flaky-test-analyzerSkill
- framework-architectSkill
- generate-api-tests-from-swaggerSkill
- generate-application-test-planSkill
- generate-automation-frameworkSkill
- generate-automation-from-testcasesSkill
- generate-automation-from-ui-flowSkill
- generate-combinatorial-test-dataSkill
- generate-cross-module-test-planSkill
- generate-locatorSkill
- generate-manual-testcases-rbtSkill
- generate-requirements-from-websiteSkill
- generate-testcases-from-requirementsSkill
- generate-test-dataSkill
- import-test-results-xraySkill
- jira-integrationSkill
- locator-healer-agentSkill
- qa-automation-engineerSkill
- rbt-manual-testingSkill
- requirements-analyzerSkill
- test-data-generatorSkill
- ui-debug-agentSkill
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
- Distinctive: line 20
Use this skill when:
- Distinctive: line 42
Use the following priority order:
- Distinctive: line 121
Before using a locator, ensure:
- Distinctive: line 133
When generating locators, provide:
≈ “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.
Files
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:
- Inspect the DOM or mobile UI hierarchy (NEVER guess)
- Identify stable attributes
- Generate a reliable locator
- Validate locator uniqueness
- Provide fallback locator if primary is fragile
Locator Priority
Use the following priority order:
- Accessibility attributes (aria-label, role)
data-testid/data-test/data-qaidname- Framework semantic locator
css selectorxpath(last option)
Note: For detailed rules, refer to
.agents/rules/locator_strategy.md.
Playwright Locators
Preferred locator methods:
getByRole()— Best for semantic elementsgetByLabel()— Best for form fields with labelsgetByPlaceholder()— Best for inputs with placeholder textgetByText()— Best for text contentgetByTestId()— 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:
iddata-testidnamecssSelectorxpath
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:
accessibility idresource-ididiOS predicate stringclass chainxpath
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:
- Primary locator — The best, most stable option
- Fallback locator — Alternative if primary breaks
- 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
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
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.

