Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/dom-testing-library/api-queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -530,15 +530,18 @@ cy.getByDisplayValue('Alaska').should('exist')
```typescript
getByRole(
container: HTMLElement,
text: TextMatch,
role: TextMatch,
options?: {
exact?: boolean = true,
normalizer?: NormalizerFn,
}): HTMLElement
```

A shortcut to `` container.querySelector(`[role="${yourRole}"]`) `` (and it also
accepts a [`TextMatch`](#textmatch)).
Queries for elements with the given role (and it also
accepts a [`TextMatch`](#textmatch)). Default roles are taken
into consideration e.g. `<button />` has the `button` role without
explicitly setting the `role` attribute. The [W3C HTML recommendation](https://www.w3.org/TR/html5/index.html#contents)
lists all HTML elements with their default aria roles.

```html
<div role="dialog">...</div>
Expand Down