locator-replacer

locator-replacer is a skill for Claude Code from DanielSuo117/velocitai. It costs 44 tokens per session (1,319 once invoked), scanned A, original, MIT.

A workflow for replacing placeholder browser locators with selectors that identify real page elements. A locator is the rule a test uses to find an element such as a button or input.

In plain words
What is it for?
It is for choosing replacement selectors, investigating the page structure, and fixing element-not-found errors.
Why use it?
It helps repair tests that cannot find elements because their locators are missing or no longer valid.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the velocitai plugin — 14 skills, 1 agent, 2 hooks shipped together

Good fit It is for choosing replacement selectors, investigating the page structure, and fixing element-not-found errors.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/danielsuo117/velocitai/locator-replacer
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.

Any agent
npx skills add DanielSuo117/velocitai --skill locator-replacer
Clone the repo
git clone --depth 1 https://github.com/DanielSuo117/velocitai

Made for: Claude Code.

Or install velocitai, the plugin that ships this one along with the rest of its 14 skills, 1 agent, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for locator-replacer

README.md
[![agentmods](https://agentmods.dev/badge/skills/danielsuo117/velocitai/locator-replacer/github.svg)](https://agentmods.dev/skills/danielsuo117/velocitai/locator-replacer)
Your own site
<a href="https://agentmods.dev/skills/danielsuo117/velocitai/locator-replacer"><img src="https://agentmods.dev/badge/skills/danielsuo117/velocitai/locator-replacer/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for locator-replacer

Your own site · 80×15
<a href="https://agentmods.dev/skills/danielsuo117/velocitai/locator-replacer"><img src="https://agentmods.dev/badge/skills/danielsuo117/velocitai/locator-replacer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 44 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,319 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00044 $0.01319
Opus 5.5 $0.00018 $0.00528
Sonnet 5.5 $0.00009 $0.00264
Haiku 4.5 $0.00004 $0.00132

Measured 2mo ago against content hash ba7d3e27c6aa, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

locator-replacer 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 2mo 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.

skills/locator-replacer/SKILL.md · 107 lines

How it starts

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

Locator Replacer — 定位符替换 Skill

适用场景

  • 将页面对象中 text= 占位定位符替换为真实选择器
  • 前端构建后原有选择器失效,需要重新定位
  • 新增页面元素需要选择最佳定位策略

定位符选择策略(六级优先级)

按优先级从高到低,逐级尝试,选中即停。优先使用页面上已有的语义化信息, 避免依赖需要前端额外配合的属性。

级别 策略 抗什么 代价
P0 ARIA role + 可见文本 CSS 重构、构建哈希 文案变更需同步
P1 可见文本 CSS 重构、构建哈希 文案变更需同步、可能不唯一
P2 表单特有属性(name/placeholder/type) 样式与文案变更 仅适用于表单控件
P3 语义化 CSS class / id 文案变更 样式重构即失效
P4 data-testid 几乎全部 需前端配合添加
P5 相对 XPath / CSS 结构 —— 最脆弱,最后手段

完整写法、判断依据与代码示例 → references/priority-levels.md

执行流程

Step 1: 分析目标页面 DOM

使用 agent-browser 打开目标页面,获取交互元素信息(工具选型遵循 agent-behavior P0.4,agent-browser 未安装时降级到 Playwright MCP):

操作步骤:
1. browser_navigate → 访问目标页面(已认证状态)
2. browser_snapshot → 获取页面无障碍树(accessibility tree)
3. browser_evaluate → 执行 JS 提取元素属性:
   - document.querySelectorAll('[data-testid]')  → 已有 testid
   - document.querySelectorAll('[role]')          → ARIA role
   - document.querySelectorAll('button, a, input') → 交互元素

Step 2: 为每个元素选择定位策略

对照页面对象中的每个占位定位符,按 P0→P5 逐级尝试,命中即停:

检查顺序 条件 使用
P0 有 role + name role=button[name='...']
P1 text= 唯一且稳定 text=...(标记"已验证唯一")
P2 表单属性(placeholder/name/type) [placeholder='...']
P3 稳定 CSS class(非哈希) css=.xxx
P4 有 data-testid [data-testid='...']
P5 以上均无 相对 XPath(≤3 层)

Step 3: 更新页面对象

class <PageName>(BasePage):
    # 定位符 — 已替换为真实选择器(<日期>)
    <PRIMARY_ACTION_BTN> = "role=button[name='<按钮文案>']"  # P0: ARIA role
    <SECONDARY_LINK> = "text=<链接文案>"                      # P1: text(已验证唯一)
    PAGE_IDENTIFIER = "role=heading[name='<页面标题>']"       # P0: ARIA role

更新规则:

  • 在定位符行尾注释标注选择级别(# P0: ARIA role / # P1: text / ... / # P4: testid / # P5: XPath)
  • 如果 text= 经验证确实稳定且唯一,注释标记 # P1: text(已验证唯一)
  • 删除原来的 # 定位符 — 后续替换为实际选择器 注释
  • 更新为 # 定位符 — 已替换为真实选择器(日期)

Read the full file on GitHub · 107 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 2mo ago Changed · -100 lines · +44 tokens per session ba7d3e27c6aa
  2. 3mo ago First seen · 207 lines · 0 tokens per session scan A 9d1eb6f47135

Subscribe to this mod's changes

locator-replacer is a skill published in the GitHub repository DanielSuo117/velocitai (159 stars, last pushed 2mo ago), licensed MIT. It adds 44 tokens to every session and 1,319 once invoked, about $0.0002 per session on Opus 5.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

locator-replacer compared with skills from other repositories

locator-replacer next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
locator-replacerDanielSuo117/velocitaiSkill1592mo agoMITA44Claude Code
cua-driverdavidondrej/skillsSkill4.4k2d agoMITA68Claude Code, Codex
create-verification-skillget-bb/bbSkill6.2ktodayMITA57Claude Code, Codex
codex-computer-usedavidondrej/skillsSkill4.4k2d agoMITA53Claude Code, Codex
webapp-testinganthropics/skillsSkill202k14d agononeA35Claude Code
test-electron-appPostHog/posthog-fossSkill733todayMITA112Claude Code
smoke-testSkyvern-AI/skyvernSkill24ktodayAGPL-3.0A50Claude Code, Codex