Playwright Aria
Exposes the ByRole
functions from Testing Library for Playwright.
Currently supports
- role
- name by regex
Get started
- Install the package:
npm i -D playwright-aria
- Follow the files in the test directory for examples on how to integrate. Roughly it's:
- import the package:
import createAriaEngine from 'playwright-aria';
- register the engine before using the aria selector:
await selectors.register('aria', createAriaEngine, { contentScript: false });
- Note: I often do this in
test.beforeAll
- Note: I often do this in
- use it in a test:
await expect(page.locator('aria=button(/test button/)')).toBeVisible();
- import the package:
Examples using the aria selector
- locate all elements with the role "button"
page.locator('aria=button')
- locate the element with the role "button" and the name matches the regex /test button/i (all regex are case insensitive for now)
page.locator('aria=button(/test button/)')