Returns an element's first child. The child element will be returned as web element JSON object (with an added .getId() convenience method).

For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide page.

Usage

Example

export default {
  demoTest(browser: NightwatchAPI): void {
    browser.element('.features-container').getFirstElementChild().then(resultElement => {
      console.log('first child element Id:', resultElement.getId());
    });
  },

  async demoTestAsync(browser: NightwatchAPI): Promise<void> {
    const resultElement = await browser.element('.features-container').getFirstElementChild();
    console.log('first child element Id:', resultElement.getId());
  }
}

Returns

Type description
ScopedWebElement