<commit_before>const BaseElementCommand = require('./_baseElementCommand.js');

/**
 * Needs to use either .executeScript() or Selenium 4 relative locators
 *
 * See also:
 *  - https://developer.mozilla.org/en-US/docs/Web/API/Element/lastElementChild
 *
 *  Example of how to get a WebElement using .execute()
 *  - https://github.com/nightwatchjs/nightwatch/issues/192#issuecomment-951730392
 *
 *
 * @method getLastElementChild
 */

class ElementCommand extends BaseElementCommand {

  get extraArgsCount() {
    return 0;
  }
  
  async protocolAction() {
    
    const result =  await this.executeProtocolAction('getLastElementChild');
    if (result && result.value) {
      const elementId = this.transport.getElementId(result.value);
      Object.assign(result.value, {
        get getId() {
          return function() {
            return elementId;
          };
        }
      });
    }

    return result;
  }
}

module.exports = ElementCommand;<commit_msg>updated description of getLastElementChild<commit_after>const BaseElementCommand = require('./_baseElementCommand.js');

/**
 * Returns an element's last child. The child element will be returned as web element JSON object (with an added .getId() convenience method).
 *
 *
 * @example
 * module.exports = {
 *  'demo Test': function(browser) {
 *     const resultElement = await browser.getLastElementChild('.features-container');
 *
 *     console.log('last child elment Id:', resultElement.getId());
 *   },
 *
 * @syntax browser.getLastElementChild(selector, callback)
 * @syntax browser.getLastElementChild(selector)
 * @param {string} [using] The locator strategy to use. See [W3C Webdriver - locator strategies](https://www.w3.org/TR/webdriver/#locator-strategies)
 * @param {string|object} selector The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies [element properties](https://nightwatchjs.org/guide#element-properties).
 * @param {function} callback Callback function which is called with the result value.
 * @method getLastElementChild
 */
class GetLastElementChild extends BaseElementCommand {

  get extraArgsCount() {
    return 0;
  }
  
  async protocolAction() {

    const result =  await this.executeProtocolAction('getLastElementChild');
    if (result && result.value) {
      const elementId = this.transport.getElementId(result.value);
      Object.assign(result.value, {
        get getId() {
          return function() {
            return elementId;
          };
        }
      });
    }

    return result;
  }
}

module.exports = GetLastElementChild;
{'fraction_non_alphanumeric': 0.11354046797084771, 'fraction_numerical': 0.00652090525508247, 'mean_word_length': 3.3758389261744965, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5387843', 'n_tokens_mistral': 742, 'n_tokens_neox': 721, 'n_words': 186}