> For the complete documentation index, see [llms.txt](https://testingvn.gitbook.io/playwright/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testingvn.gitbook.io/playwright/playwright-locator-elements/user-first-locator-stratergy.md).

# User-first locator stratergy

Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent a way to find element(s) on the page at any moment. ​Playwright is a robust automation framework for web applications, offering a variety of locator strategies to interact with web elements effectively. Utilizing the appropriate locator methods enhances test reliability and maintainability.

**These are the recommended built-in locators.**

1. page.getByRole() to locate by explicit and implicit accessibility attributes.&#x20;
2. page.getByText() to locate by text content.
3. page.getByLabel() to locate a form control by associated label's text.
4. page.getByPlaceholder() to locate an input by placeholder.
5. page.getByAltText() to locate an element, usually image, by its text alternative.
6. page.getByTitle() to locate an element by its title attribute.
7. page.getByTestId() to locate an element based on its data-testid attribute (other attributes can be configured).

### References:

{% embed url="<https://www.youtube.com/shorts/EaHdpSKYBH8>" %}

{% embed url="<https://www.youtube.com/shorts/BUl1sfAqLeQ>" %}

{% embed url="<https://www.youtube.com/watch?v=chzfI57fhQ8>" %}
