Search for multiple elements on the page, starting from the document root. The located elements will be returned as web element JSON objects (with an added .getId() convenience method).

First argument is the element selector, either specified as a string or as an object (with 'selector' and 'locateStrategy' properties).

Syntax

browser.findElements(selector, callback)
await browser.findElements(selector);

Parameters

Name Type description
selector string

The search target.

callback
Optional
function

Callback function to be invoked with the result when the command finishes.

Usage

describe('findElements', function() {
 it('finds elements on a page', async function(browser) {
   const resultElements = await browser.findElements('.features-container li');
   resultElements.forEach(item => console.log('Element Id:', item.getId()));
 }};
});

See also

W3C WebDriver spec: