generate_locator

A command that creates stable selectors for finding buttons, fields, and other elements in web or mobile interfaces. It supports Playwright, Selenium, and Appium.

In plain words
What is it for?
Use it to create or review selectors from an element description, URL, screenshot, or HTML snippet. It helps automate websites and mobile apps with Playwright, Selenium, or Appium.
Why use it?
It reduces fragile tests caused by selectors that stop working when a page changes. It checks the real page structure and whether the selector matches only the intended element.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/anhtester/claude-testing-kit/generate_locator
Clone the repo
git clone --depth 1 https://github.com/anhtester/claude-testing-kit

Made for: Claude Code.

Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,012 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00020 $0.03012
Opus 5 $0.00010 $0.01506
Sonnet 5 $0.00004 $0.00602
Haiku 4.5 $0.00002 $0.00301

Measured 3d ago against content hash c7a93d37cf43, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

generate_locator scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.claude/commands/generate_locator.md · 334 lines

How it starts

The opening of the file, as written. The whole thing — 334 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/generate_locator — Sinh Locator Ổn Định Cho UI Automation

User cung cấp element cần tìm locator (mô tả, screenshot, URL, hoặc HTML snippet). AI inspect DOM/UI hierarchy thực tế, sinh locator ổn định theo priority chuẩn, verify uniqueness, trả về kết quả.

BẮT BUỘC (MANDATORY): Trước khi bắt đầu, PHẢI nạp và đọc kỹ:

  • Skill: .claude/skills/skills-smart-locator-agent/SKILL.md — Quy trình sinh locator
  • Skill: .claude/skills/skills-ui-debug-agent/SKILL.md — Quy trình inspect DOM
  • Rule: .claude/rules/locator_strategy.md — Bản đồ ưu tiên locator
  • Rule: .claude/rules/<framework>_rules.md — Quy tắc riêng framework đang dùng

Input cần từ User

Input Bắt buộc Mô tả
Mô tả element VD: "nút Login", "dropdown chọn Country", "ô nhập Email"
URL trang chứa element Để AI navigate và inspect DOM thực tế
Framework playwright, selenium, hoặc appium
HTML snippet Nếu User đã có sẵn DOM context — AI dùng để phân tích nhanh
Page class đích File Page class mà locator sẽ được thêm vào
Login yêu cầu Nếu trang yêu cầu đăng nhập — User cho biết cách login

Lưu ý về Login: Nếu trang yêu cầu đăng nhập, User PHẢI chỉ rõ cách login (fixture, script, URL login...). AI KHÔNG ĐƯỢC tự đọc .env hay đoán credentials.


Các bước thực hiện

Phase 1: Phân tích yêu cầu

  1. Hiểu element cần tìm — Xác định rõ:

    • Loại element: button, input, link, dropdown, dialog, table row, checkbox, radio...
    • Context: Nằm trong page chính, dialog/modal, sidebar, table, iframe?
    • Thao tác: click, fill, select, hover, verify text, verify visibility?
  2. Xác định framework và đọc rules tương ứng:

    Framework Rule file
    Playwright .claude/rules/playwright_rules.md
    Selenium .claude/rules/selenium_rules.md
    Appium .claude/rules/appium_rules.md
  3. Kiểm tra Page class hiện tại (nếu User chỉ định):

    • Đọc file Page class → biết locator đã có sẵn
    • Tránh trùng lặp hoặc xung đột naming

Read the full file on GitHub · 334 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 334 lines · 20 tokens per session scan A c7a93d37cf43

Subscribe to this mod's changes

generate_locator is a command published in the GitHub repository anhtester/claude-testing-kit (49 stars, last pushed 25d ago), licensed MIT. It adds 20 tokens to every session and 3,012 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other commands, from other repositories

generate_automation_from_testcases

Convert manual test cases into automation scripts autonomously using the 6-step AI-RBT Framework via Antigravity Capabilities.

anhtester/ClaudeCode_Playwright_Demo · 25 tokens

generate_automation_from_ui_flow

Thực thi UI flow trực tiếp trên browser, thu thập locators từ DOM thực tế, và sinh automation scripts. Hỗ trợ Playwright, Selenium, Appium.

anhtester/ClaudeCode_Playwright_Demo · 36 tokens

expect

Diff-aware AI browser testing — reads the git diff, maps changes to affected pages via the route map, generates a targeted test plan, and executes it via agent-browser (Rust daemon + CDP, ARIA-tree-first) with pass/fail reporting. Use when testing UI changes, verifying PRs before merge, or running regression checks on…

yonatangross/orchestkit · 73 tokens

stark-quality-gate

Use this command when a web UI should be maintained, released, compared across runs, or used as public proof. It turns visual QA into a repeatable local/CI gate instead of a one-off screenshot check.

f0d010c/stark · 0 tokens

open

SoDam-Design-Kit open 대시보드 — 검증 이력·판정서·스크린샷을 브라우저로 열람 + 재검증.

sodam-ai/SoDam-Design-Kit · 36 tokens

playwright-cli

Use this skill whenever the user wants to automate a browser, scrape web content, take screenshots or PDFs of pages, fill out forms, click through UI flows, or run end-to-end tests — without using an MCP server. This skill drives Playwright directly from the bashtool via Node.js scripts. Trigger whenever the user says…

fwornle/coding · 145 tokens