Skip to content

Document default aria roles consideration #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

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