Types a key sequence on the DOM element. Can be used to send a sequence of key strokes to an element. Any UTF-8 character may be specified.

An object map with available keys and their respective UTF-8 characters, as defined on W3C WebDriver draft spec, is loaded onto the main Nightwatch instance as browser.Keys.

sendKeys() will automatically wait for the element to be present (until the specified timeout). If the element is not found, an error is thrown which will cause the test to fail. Starting with v1.2 you can suppress element not found errors by specifying the suppressNotFoundErrors option.


.sendKeys(selector, inputValue, [callback])


Name Type description

The locator strategy to use. See W3C Webdriver - locator strategies

selector string|object

The selector (CSS/Xpath) used to locate the element. Can either be a string or an object which specifies element properties.

inputValue string|array

The text to send to the element or key strokes.


Optional callback function to be called when the command finishes.


// send some simple text to an input
this.demoTest = function (browser) {
  browser.sendKeys('input[type=text]', 'nightwatch');
// send some text to an input and hit enter.
this.demoTest = function (browser) {
  browser.sendKeys('input[type=text]', ['nightwatch', browser.Keys.ENTER]);

W3C WebDriver spec