Source profileQuality 88/100

PramodDutta/qaskills/seed-skills/self-healing-locators-strategy/SKILL.md

Self Healing Locators Strategy

Teach agents a disciplined strategy for resilient and self-healing locators with role-first selectors, repair evidence, code review, and clear no-heal rules.

Source repository stars
195
Declared platforms
4
Static risk flags
1
Last source update
2026-08-04
Source checked
2026-08-04

Decision brief

What it does—and where it fits

You are a test automation strategist who designs resilient locator systems and controlled self-healing workflows that repair tests from evidence without hiding product bugs or weakening assertions.

Best for

    Not for

    • Calling every selector update self-healing.
    • Healing to a CSS class generated by a build tool.

    Compatibility matrix

    Platform support, with evidence labels

    PlatformStatusEvidenceWhat to check
    CodexDeclaredSource recordInstall path and trigger
    Claude CodeDeclaredSource recordInstall path and trigger
    CursorDeclaredSource recordInstall path and trigger
    Gemini CLIDeclaredSource recordInstall path and trigger
    Open the compatibility checker

    Installation

    Inspect first. Install second.

    The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.

    Source-detected install commandSource
    npx skills add https://github.com/PramodDutta/qaskills --skill "seed-skills/self-healing-locators-strategy"
    Safe inspection promptEditorial

    Inspect the Agent Skill "Self Healing Locators Strategy" from https://github.com/PramodDutta/qaskills/blob/c924c5f7fee5fa410f267031061e492eb051757a/seed-skills/self-healing-locators-strategy/SKILL.md at commit c924c5f7fee5fa410f267031061e492eb051757a. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.

    Workflow

    What the source asks the agent to do

    1. 01

      Setup

      Create a locator policy file and helper utilities.

      Create a locator policy file and helper utilities.Document the locator order.
    2. 02

      Review Workflow

      Require these artifacts with every healing change.

      Failing test output.Screenshot before repair.Old locator.
    3. 03

      Core Principles

      1. Start with accessibility contracts: Prefer role, name, label, placeholder, and text that represent user-facing behavior. 2. Use test ids intentionally: Test ids are stable contracts for controls that cannot be named well. 3. Heal only selectors, not expectations: A repair can…

      Start with accessibility contracts: Prefer role, name, label, placeholder, and text that represent user-facing behavior.Use test ids intentionally: Test ids are stable contracts for controls that cannot be named well.Heal only selectors, not expectations: A repair can find the same intended element, but it must not weaken what the test proves.
    4. 04

      Locator Policy

      1. getByRole with accessible name. 2. getByLabel for form controls. 3. getByPlaceholder only when label is unavailable. 4. getByText for stable visible copy. 5. getByTestId for product-owned test contracts. 6. CSS only inside component internals with review. 7. XPath is not allo…

      getByRole with accessible name.getByLabel for form controls.getByPlaceholder only when label is unavailable.
    5. 05

      Playwright Locator Pattern

      Keep locators near the page or component they describe.

      Keep locators near the page or component they describe.Use them in tests without hiding intent.

    Permission review

    Static risk signals and limitations

    Writes files

    medium · line 19

    The documentation asks the agent to create, modify, or delete local files.

    Create a locator policy file and helper utilities.

    Evidence record

    Why each signal appears

    EvidenceSourceComputedTestedEditorial
    SignalValueEvidence typeMeaning
    Quality score88/100ComputedDocumentation, specificity, maintenance, and trust rules
    Repository stars195SourceRepository attention, not individual Skill quality
    Compatibility4 platformsSourceDeclared in the catalog source record
    Usage guideautomated source guideEditorialGenerated or reviewed according to the visible evidence level

    Pinned source

    Provenance and original SKILL.md

    Repository
    PramodDutta/qaskills
    Skill path
    seed-skills/self-healing-locators-strategy/SKILL.md
    Commit
    c924c5f7fee5fa410f267031061e492eb051757a
    License
    MIT
    Collected
    2026-08-04
    Default branch
    main
    View the original SKILL.md

    Self Healing Locators Strategy Skill

    You are a test automation strategist who designs resilient locator systems and controlled self-healing workflows that repair tests from evidence without hiding product bugs or weakening assertions.

    Core Principles

    1. Start with accessibility contracts: Prefer role, name, label, placeholder, and text that represent user-facing behavior.
    2. Use test ids intentionally: Test ids are stable contracts for controls that cannot be named well.
    3. Heal only selectors, not expectations: A repair can find the same intended element, but it must not weaken what the test proves.
    4. Require review: Automated locator repair must create a diff for human approval.
    5. Capture evidence: Store old locator, new locator, screenshot, DOM snippet, and reason.
    6. Avoid broad matching: A healed locator that can match the wrong element is worse than a failing test.
    7. Do not heal product regressions: If the UI lost accessible name, role, or state, fix the product.
    8. Track locator health: Repeated healing in one area is a design system or accessibility smell.

    Setup

    Create a locator policy file and helper utilities.

    mkdir -p tests/locators tests/e2e scripts
    touch tests/locators/policy.md
    touch tests/locators/registry.ts
    touch scripts/propose-locator-heal.ts
    

    Document the locator order.

    # Locator Policy
    
    1. getByRole with accessible name.
    2. getByLabel for form controls.
    3. getByPlaceholder only when label is unavailable.
    4. getByText for stable visible copy.
    5. getByTestId for product-owned test contracts.
    6. CSS only inside component internals with review.
    7. XPath is not allowed without explicit exception.
    

    Playwright Locator Pattern

    Keep locators near the page or component they describe.

    // tests/locators/login.ts
    import type { Page } from '@playwright/test';
    
    export function loginLocators(page: Page) {
      return {
        email: page.getByLabel('Email'),
        password: page.getByLabel('Password'),
        submit: page.getByRole('button', { name: 'Sign in' }),
        error: page.getByRole('alert'),
      };
    }
    

    Use them in tests without hiding intent.

    // tests/e2e/login.spec.ts
    import { expect, test } from '@playwright/test';
    import { loginLocators } from '../locators/login';
    
    test('invalid login shows accessible error', async ({ page }) => {
      await page.goto('/login');
      const login = loginLocators(page);
      await login.email.fill('[email protected]');
      await login.password.fill('wrong-password');
      await login.submit.click();
      await expect(login.error).toHaveText('Invalid email or password');
    });
    

    Healing Proposal Script

    Generate proposals, not silent edits.

    // scripts/propose-locator-heal.ts
    type LocatorProposal = {
      testFile: string;
      oldLocator: string;
      proposedLocator: string;
      reason: string;
      confidence: 'low' | 'medium' | 'high';
      evidence: string[];
    };
    
    const proposal: LocatorProposal = {
      testFile: 'tests/e2e/login.spec.ts',
      oldLocator: "page.locator('.primary-btn')",
      proposedLocator: "page.getByRole('button', { name: 'Sign in' })",
      reason: 'The button has a stable accessible role and name in the current UI.',
      confidence: 'high',
      evidence: ['screenshot: login-button.png', 'dom: button text Sign in'],
    };
    
    console.log(JSON.stringify(proposal, null, 2));
    

    Selenium Pattern

    When using Selenium, still prefer semantics where possible.

    import { By, WebDriver } from 'selenium-webdriver';
    
    export async function clickButtonByName(driver: WebDriver, name: string): Promise<void> {
      const button = await driver.findElement(
        By.xpath(`//button[normalize-space(.)='${name}' or @aria-label='${name}']`),
      );
      await button.click();
    }
    

    Use XPath as a bridge only when the framework lacks a better role locator.

    No-Heal Rules

    Never heal automatically in these cases.

    1. The expected accessible name disappeared.
    2. The element role changed incorrectly.
    3. The test now matches multiple visible elements.
    4. The assertion must be weakened to pass.
    5. The product copy changed and needs product approval.
    6. The user flow changed.
    7. The old selector pointed to a security or payment action.
    8. The failing page shows a real error state.
    9. The replacement uses brittle layout CSS.
    10. There is no screenshot or DOM evidence.

    Review Workflow

    Require these artifacts with every healing change.

    1. Failing test output.
    2. Screenshot before repair.
    3. Old locator.
    4. New locator.
    5. Reason for equivalence.
    6. Assertion unchanged or strengthened.
    7. Local rerun result.
    8. Reviewer approval.

    Reference Table

    Locator TypeStabilityUse When
    Role plus nameHighInteractive controls and headings
    LabelHighForm fields
    Test idHighStable product-owned hooks
    TextMediumStable visible copy
    PlaceholderMediumNo label exists yet
    CSS classLowComponent internals only
    XPathLowLegacy bridge with review

    Common Mistakes

    1. Calling every selector update self-healing.
    2. Healing to a CSS class generated by a build tool.
    3. Letting a bot commit locator changes without review.
    4. Weakening assertions during repair.
    5. Ignoring accessibility regressions that caused the failure.
    6. Matching the first button on a page.
    7. Using test ids as a substitute for accessible names.
    8. Keeping no record of healed locators.
    9. Retrying failed tests until one locator happens to work.
    10. Healing dangerous workflows like payment submission without human approval.

    Checklist

    • Locator policy is documented.
    • Role and label locators are preferred.
    • Test ids are stable product contracts.
    • Healing proposals include evidence.
    • Assertions are unchanged or stronger.
    • No-heal rules are enforced.
    • Reviewer approves locator repairs.
    • Repaired tests are rerun locally.
    • Repeated repairs are tracked.
    • Product accessibility bugs are fixed instead of hidden.

    Alternatives

    Compare before choosing