Search for an element on the page, starting from the identified element. The located element will be returned as a Web Element JSON object.

This command operates on a protocol level and requires a Web Element ID. Read more on Element retrieval on the W3C WebDriver spec page.

Please note that this command operates on a protocol level and accepts the Web Element ID as the parameter. To retrieve it, use either the .element() or .elements() command. Read more on Element retrieval.

Usage:

.elementIdElement(webElementId, using, value, callback)

Parameters:

Name Type description
webElementId string

The Web Element ID of the element to route the command to.

using string

The locator strategy to use.

value string

The search target.

callback function

Callback function which is called with the result value.

Example:

module.exports = {
 'demo Test' : function(browser) {
    browser.elementIdElement('<WebElementId>', 'css selector', '.new-element', function(result) {
      console.log(result.value)
    });
  },

  'es6 async demo Test': async function(browser) {
    const result = await browser.elementIdElement('<WebElementId>', 'css selector', '.new-element');
    console.log(result.value);
  },

  'page object demo Test': function (browser) {
     var nightwatch = browser.page.nightwatch();
     nightwatch.navigate();

     const navbarHeader = nightwatch.section.navbarHeader;

     navbarHeader.api.elementIdElement('@versionDropdown', 'css selector', 'option', function(result) {
       browser.assert.ok(client.WEBDRIVER_ELEMENT_ID in result.value, 'The Webdriver Element Id is found in the result');
     });
  }
}

W3C WebDriver spec: