Search 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 the area-selected attribute with true or false value.
  • checked - picks elements that has the area-checked attribute with true or false value.
  • pressed - picks elements that has the area-pressed attribute with true or false value.
  • current - picks elements that has the area-current attribute with true or false value.
  • level - picks elements that has the area-level attribute with true or false value. This option is suitable only for the heading role.
  • expanded - picks elements that has the area-expanded attribute with true or false value.

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
options
Optional
[object Object]

Returns

Type description
Array.<ScopeWebElement>