Skip to content
Bugwise
Menu

Locator

Also called: Selector

The way an automated test finds an element on the screen, such as a button or a field.

Definition

Good locators find elements the way a user would: by role and visible name, label, text, or a dedicated test ID. Locators based on long CSS paths or element positions break whenever the layout changes. Elements without accessible names are hard to locate, so accessibility and automation help each other.

In practice

getByRole('button', { name: 'Book' }) keeps working after a redesign; locator('div > button:nth-child(3)') doesn't.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.