An alias of "setValue" command, but hides the content from the nightwatch logs.

setValue/setPassword also clears the existing value of the element by calling the clear() command beforehand.

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.

The command setPassword() 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. You can suppress element not found errors by specifying the selector argument as an object and passing the suppressNotFoundErrors = true option.

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

Usage

                    .setPassword(selector, inputValue, [callback])
                
                    .setPassword(using, selector, inputValue, [callback])
                

Example

// send some simple text to an input
this.demoTest = function (browser) {
  browser.setPassword('input[type=text]', 'nightwatch');
};

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

Parameters

Name Type description
using
Optional
string

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.

callback
Optional
function

Optional callback function to be called when the command finishes.

W3C WebDriver spec