.setAttribute() Suggest edits
Since: 3.0.0Set the value of a specified DOM attribute for the given element. For all the available DOM attributes, consult the Element doc at MDN.
For more info on working with DOM elements in Nightwatch, refer to the Finding & interacting with DOM Elements guide page.
Usage
browser.element(selector).setAttribute(name, value)
Example
export default {
demoTest(browser: NightwatchAPI): void {
browser.element('#login input[type=text]').setAttribute('disabled', true);
},
async demoTestAsync(browser: NightwatchAPI): Promise<void> {
await browser.element('#login input[type=text]').setAttribute('disabled', true);
}
}
Parameters
Name | Type | description |
---|---|---|
name |
string | The attribute name to set. |
value |
The attribute value name to set. |
Returns
Type | description |
---|---|
ScopedWebElement |