Search for multiple elements on the page, starting from the identified element. The located element will be returned as a web element JSON objects.

For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide 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 .findElement() or .findElements() command. Read more on Element retrieval.

Usage

                    .elementIdElements(webElementId, using, value, [callback])
                

Example

module.exports = {
 'demo Test' : function(browser) {
    browser.elementIdElements('<WebElementId>', 'css selector', 'ul li', function(result) {
      console.log(result.value)
    });
  },

  'es6 async demo Test': async function(browser) {
    const result = await browser.elementIdElements('<WebElementId>', 'css selector', 'ul li');
    console.log(result.value);
  },

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

     const navbarHeader = nightwatch.section.navbarHeader;

     navbarHeader.api.elementIdElements('@versionDropdown', 'css selector', 'option', function(result) {
       browser.assert.equal(result.value.length, 2, 'There are two option elements in the drop down');
     });
  }
}

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.

W3C WebDriver spec