Playwright · Matcher
toHaveRole
toHaveRole checks that a locator points to an element with a specific ARIA role. It retries until the role matches or the assertion timeout is reached.
Last updated
- Since
- v1.44
Syntax
await expect(locator).toHaveRole(role, options);In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.
SubscribeRelated
expectLocatorgetByRolegetByTestIdtoBeVisibletoHaveAccessibleName