.findAllByRole() Suggest edits
Since: 3.0.0Search for elements on the page that meet the provided ARIA role.
Elements can be searched by using another element as the starting point.
You can pass some options to narrow the search:
selected- picks elements that has thearea-selectedattribute withtrueorfalsevalue.checked- picks elements that has thearea-checkedattribute withtrueorfalsevalue.pressed- picks elements that has thearea-pressedattribute withtrueorfalsevalue.current- picks elements that has thearea-currentattribute withtrueorfalsevalue.level- picks elements that has thearea-levelattribute withtrueorfalsevalue. This option is suitable only for theheadingrole.expanded- picks elements that has thearea-expandedattribute withtrueorfalsevalue.
Usage
browser.element.findAllByRole(role, [options])
Example
export default {
demoTest(browser: NightwatchAPI): void {
const comboboxes = browser.element.findAllByRole('combobox');
const headings = browser.element.findAllByRole(
'heading',
{ level: 2 }
);
}
}
Parameters
| Name | Type | description |
|---|---|---|
role |
string | |
optionsOptional |
[object Object] |
Returns
| Type | description |
|---|---|
| Array.<ScopeWebElement> |