Buttons (role="button")
page.getByRole('button', { name: 'Submit Form' })
Links (role="link")
page.getByRole('link', { name: 'About Us' })
Headings (role="heading")
Main Title H1
Section Title H2
Subsection Title H3
page.getByRole('heading', { name: 'Main Title H1', level: 1 })
Checkboxes & Radio (role="checkbox", role="radio")
page.getByRole('checkbox', { name: 'I agree to Terms of Service' })
Textbox (role="textbox")
page.getByRole('textbox', { name: 'Search products' })
Combobox (role="combobox")
page.getByRole('combobox', { name: 'Country selection' })
Table (role="table", "row", "cell")
| ID | Name | Status | |
|---|---|---|---|
| 1 | John Doe | john@example.com | Active |
| 2 | Jane Smith | jane@example.com | Pending |
| 3 | Bob Wilson | bob@example.com | Inactive |
page.getByRole('table', { name: 'User data table' })
page.getByRole('row', { name: /John Doe/ })
page.getByRole('row', { name: /John Doe/ })
Dialog (role="dialog")
Confirmation Dialog
Are you sure you want to proceed?
page.getByRole('dialog')
page.getByRole('dialog').getByRole('button', { name: 'Confirm' })
page.getByRole('dialog').getByRole('button', { name: 'Confirm' })