locator-replacer

Replace placeholder locators in page objects with stable selectors using six-level prioritization.

176|2|Updated May 21, 2026
One-click install
npx skills add https://github.com/DanielSuo117/velocitai --skill locator-replacer
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: locator-replacer
Source: https://github.com/DanielSuo117/velocitai/tree/main/zh/skills/locator-replacer
Command: npx skills add https://github.com/DanielSuo117/velocitai --skill locator-replacer

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill replaces placeholder locators in page object models with real, stable selectors using a six-tier priority strategy to improve test reliability.

Core Features & Use Cases

  • Six-level locator strategy: P0 ARIA-role based, P1 text, P2 form attributes, P3 stable CSS classes (non-hash), P4 data-testid, P5 relative XPath.
  • Automated page object updates: rebinds existing elements with the new selectors and annotates their priority in comments.
  • Supports progressively updating tests after DOM changes and during UI refactors, minimizing flakiness.
  • Example: when a text placeholder becomes dynamic, locate with role+name or text first, then fallback to attributes or XPath.

Quick Start

Run the locator-replacer over your page objects to replace placeholders with concrete selectors.

Frequently Asked Questions about locator-replacer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I replace placeholder locators in page objects with real selectors?

To replace placeholder locators in page objects, run the locator-replacer over your page object models to automatically bind concrete selectors using a six-tier priority strategy and annotate their priority in code comments.

What is the best locator strategy for UI test automation to minimize flakiness?

The best locator strategy for UI test automation uses a six-level prioritization: P0 ARIA roles, P1 text, P2 form attributes, P3 stable CSS classes, P4 data-testid, and P5 relative XPath, ensuring stable element targeting across DOM changes.

How do I update unstable text-based locators after a UI refactor?

To update unstable text-based locators after a UI refactor, apply a six-level locator replacement strategy that rebinds existing page object elements with stable selectors, prioritizing ARIA roles and form attributes over dynamic text.

When should I use XPath instead of data-testid for web page selectors?

You should use relative XPath (P5) instead of data-testid (P4) only when higher-priority locators like ARIA roles, text, form attributes, and stable CSS classes are unavailable for identifying the target web element.

Can I automatically annotate page object code with locator priority levels?

Yes, you can automatically annotate page object code with locator priority levels, as the replacement process updates scripts and references by rebinding elements with new selectors and adding priority comments from P0 through P5.