Decision

Selector survival

Predict which UI locators will break in the next release before they break your tests — what to send, what the answers mean, and how to act on them.

Task: selector_survival · MCP tool: ostra_check_selector · Price: $0.25 per 1M locators ($0.125 in a batch)

Selector survival answers will this locator survive the next release? Run it on the locators your tests depend on before a release, or on the locators a pull request adds, and replace the ones likely to break before they cost you a red build.

What to send

input.locators is a list of 1 to 500 locators. For each:

FieldWhat it isWhere to get it
locator_idYour name for the locator, echoed back.Page-object property names work well: checkout.apply-coupon.
strategyHow it finds its element: css, xpath, test_id, text, role, none.Playwright getByTestId → test_id, getByRole → role, getByText → text, locator('//…') → xpath, other locator() → css. Cypress cy.get('[data-cy=…]') → test_id. Selenium By.xpath → xpath, By.cssSelector → css.
dom_locator_foundWhether it matches an element in the current build's DOM.Open the page in the build under test and check the locator (await page.locator(sel).count() > 0).
historyUp to 100 { release, resolve_rate } entries, oldest first. resolve_rate (0–1) is the share of runs in that release where the locator resolved.Record it per release from your test runs, or from the check above (1.0 found, 0.0 not found).

A locator with no history and no dom_locator_found carries no evidence and gets defer (insufficient_evidence).

Example

curl https://ostra.testrelic.ai/api/v1/predict \
  -H "Authorization: Bearer $OSTRA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ostra-lite",
    "task": "selector_survival",
    "input": {
      "locators": [
        {
          "locator_id": "checkout.apply-coupon",
          "strategy": "css",
          "dom_locator_found": true,
          "history": [
            { "release": "2026.10.1", "resolve_rate": 1.0 },
            { "release": "2026.10.2", "resolve_rate": 0.92 },
            { "release": "2026.11.1", "resolve_rate": 0.71 }
          ]
        },
        {
          "locator_id": "nav.account-menu",
          "strategy": "role",
          "dom_locator_found": true,
          "history": [
            { "release": "2026.10.2", "resolve_rate": 1.0 },
            { "release": "2026.11.1", "resolve_rate": 1.0 }
          ]
        }
      ]
    }
  }'

output (trimmed to the key fields):

{
  "decisions": [
    { "locator_id": "checkout.apply-coupon", "decision": "breaks", "p": 0.78, "probabilities": { "survives": 0.22, "breaks": 0.78 } },
    { "locator_id": "nav.account-menu", "decision": "survives", "p": 0.96, "probabilities": { "survives": 0.96, "breaks": 0.04 } }
  ]
}

Decisions come back in input order. This request is billed for 2 locators.

Answers and what to do

decisionMeansNext step
survivesThe locator is expected to keep working.Nothing.
breaksThe locator is likely to stop matching in the next release.Replace it with a sturdier one before release: prefer getByRole with an accessible name, or a dedicated test id.
deferNot enough evidence or not confident.Add history or a DOM check, or review it by hand.

A falling resolve_rate across releases (like checkout.apply-coupon above) is the clearest warning sign; CSS and XPath locators tied to layout break more often than role and test-id locators.

Getting better answers

  • Keep history. Record each locator's resolve rate per release; even three releases help a lot.
  • Check the current DOM. dom_locator_found is cheap to compute in a preview environment.
  • Use stable ids. Name locator_id after the page object so results map straight back to code.
  • Batch. One request takes up to 500 locators; /batch halves the price.

Check selectors before release has a complete script and CI job.

Reference

Was this page helpful?

On this page