Search for an elements on the page, starting from the document root. The located element will be returned as web element JSON object (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).

Usage

browser.findElement(selector, callback)
await browser.findElement(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.

Example

module.exports = {
 'demo Test': function(browser) {
    const resultElement = await browser.findElement('.features-container li:first-child');

    console.log('Element Id:', resultElement.getId());
  },

W3C WebDriver spec