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