On this page
Finding the same element on the next run
A test automation suite usually breaks because a CSS selector moved, not because the app did. xtest never stores one selector. Every action the AI takes records a bundle of facts about the element: its test id, its accessible role and name, its label, its text, a short CSS path. Replay tries them in order, so a changed class name is the last thing it would miss on.
The order replay tries
Test id
data-testid, data-test, data-qa or data-cy. If your team writes one of these, nothing below is ever needed.
id
Only an id that does not look generated.
Role and name
The accessible role with the accessible name, plus an nth when that pair appears more than once on the page.
Label
The field's label, for inputs and selects.
Placeholder
The placeholder text, when there is no label.
Visible text
What the element reads on screen.
A short CSS path
At most four segments, built only from ids and class names that do not look generated.
A point
Last resort, and only for an action with no element under it: the coordinate and the viewport size it was measured in.
{
"role": "button",
"name": "Add to basket",
"nth": 2,
"id": "add-to-basket",
"text": "Add to basket",
"css": "main > .product > .actions > button"
}What counts as a generated name
Three or more digits in a row, a hex or uuid-ish blob of sixteen characters or more, or a framework prefix: ember-, react-, radix-, headlessui-, mui-. Names like those change on the next deploy, so xtest refuses to remember an element by one. That is why a saved step survives a rebuild that renames every class.
When every one of them misses
The step is marked failed and replay stops there. The AI picks the test up from that step, with the steps that already passed behind it, works out what the element became and finishes the test. The repaired step is saved, so the next run replays it at no AI cost unless a step needs it; a repair that would change what the test checks waits for your approval first. Nothing before the broken step is re-run and no model is called for the part that worked.
How to make your app easy to test
Put a data-testid on anything a test will touch, and give every control a real accessible name. Both are the first two things tried, both are cheap, and both also make the app work with a screen reader. Nothing else on this page needs your attention.
On a phone
The same idea with native facts: the accessibility id, a class chain or predicate on iOS, a UiSelector on Android, an xpath, the class name, and a point as the last resort. Saved steps are kept per platform, so a test can hold one set of steps for the web and another for the iPhone simulator.