1. getByRole() Locators
Locate elements by their explicit or implicit ARIA roles.
Buttons
Div with button role
Form Elements
Navigation
This is an important alert message!
2. getByText() Locators
Locate elements by their text content.
This paragraph contains some important text that you might want to locate.
Another paragraph with colored text for demonstration.
- List item 1
- List item 2 with link
- Special: Unique text identifier
Click the button above to submit your information.
3. getByLabel() Locators
Locate form controls by their associated label text.
4. getByPlaceholder() Locators
Locate input elements by their placeholder text.
5. getByAltText() Locators
Locate elements (usually images) by their alt text.
Playwright Logo