diagnostic · one of 39 Pro saves the page object
Selector health
Which of these locators will survive the next refactor?
A brittle locator works perfectly until the markup moves, which is why flaky suites are usually discovered months after the decision that caused them. This walks every interactive element on the page, works out the best selector available for each, and scores it - a test id at the top, a path through the tree at the bottom - with the attribute worth adding named on the row.
Reach it Press ⌘ + K on any tab and type selector health. Ctrl + K on Windows and Linux
in the panel · this one is Pro
What this actually is
how durable each interactive element is to address in a testBefore writing a suite against a page somebody else built, and during a refactor that is about to move markup around. It measures durability rather than correctness: a three-deep path is a perfectly working locator today and a broken one after the next insertion.
What a selector is built out of
best first, and the score each is worth- test id
- survives a rewrite of everything around it
- id
- stable unless the id is generated per render
- label
- breaks when the label copy changes
- role and name
- the name is copy, so a wording change breaks it
- text
- breaks on a rewrite or a translation
- class
- breaks the moment styling is refactored or utilities are generated
- tag
- unique today by accident, not by intent
- position
- the next element inserted above it breaks this
Asked about this diagnostic
3 of themWhich frameworks does the page object come out in?
Playwright, Cypress, Puppeteer, WebdriverIO and Testing Library. The locator is decomposed once and each dialect writes it in its own idiom, so the output is what you would have typed rather than a Playwright string wrapped in something else.
Is a low score a bug?
No, and that distinction is the whole reading. Every locator on the list works right now against the page in front of you. The score says how long it is likely to keep working, which is a different question and the one a test suite actually depends on.
What about a page with hundreds of controls?
It is sampled rather than walked whole above a cap, and the screen says which it did. A mean over a sample is still the number you want; a walk that takes a minute on a large application is not.
how to use selector health
- Open Selector health. Every interactive element on the page is walked and scored.
- Read the mean first, then switch to Brittle - the rows under forty are the list to act on.
- Take the advice on a bad row: it names the attribute that would move it to the top of the scale.
- Generate the page object in your framework once the page scores well enough to be worth one.
75 of these · no host permissions · three free audits