Clear a textarea or a text input element's value.
This command has no effect if the underlying DOM element is neither a text INPUT element nor a TEXTAREA element.

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

Usage

                    browser.element(selector).clear()
                

Example

export default {
  demoTest(browser: NightwatchAPI): void {
    browser.element('input[type=text]').clear();

    browser.element('textarea').clear();
  },
  async demoTestAsync(browser: NightwatchAPI): Promise<void> {
    await browser.element('input[type=text]').clear();

    await browser.element('textarea').clear();
  }
}

Returns

Type description
ScopedWebElement

W3C WebDriver spec