.updateValue() Suggest edits
Sends some text to an element. Can be used to set the value of a form element or 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
.
The command updateValue()
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.
Usage
.updateValue(selector, inputValue, [callback])
Example
// send some simple text to an input
this.demoTest = function (browser) {
browser.updateValue('input[type=text]', 'nightwatch');
};
// send some text to an input and hit enter.
this.demoTest = function (browser) {
browser.updateValue('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. |