# Locator Priority Use the first option that works: | Priority | Locator | Use for | |---|---|---| | 1 | `getByRole('button', { name: 'Submit' })` | Buttons, links, headings, form elements | | 2 | `getByLabel('Email address')` | Form fields with associated labels | | 3 | `getByText('Welcome back')` | Non-interactive text content | | 4 | `getByPlaceholder('Search...')` | Inputs with placeholder text | | 5 | `getByAltText('Company logo')` | Images with alt text | | 6 | `getByTitle('Close dialog')` | Elements with title attribute | | 7 | `getByTestId('checkout-summary')` | When no semantic option exists | | 8 | `page.locator('.legacy-widget')` | CSS/XPath — absolute last resort | ## Role Locator Cheat Sheet ```typescript // Buttons —