addValue
Add a value to an object found by given selector. You can also use unicode
characters like Left arrow or Back space. WebdriverIO will take care of
translating them into unicode characters. You’ll find all supported characters
here.
To do that, the value has to correspond to a key from the table. It can be disabled
by setting translateToUnicode
optional parameter to false.
Usage
$(selector).addValue(value, { translateToUnicode })
Parameters
Name | Type | Details |
---|---|---|
value | string , number , Array.<string, number> | value to be added |
options optional | CommandOptions | command options (optional) |
options.translateToUnicode | boolean | enable translation string to unicode value automatically |
Example
- Asynchronous Mode
- Synchronous Mode
addValue.js
it('should demonstrate the addValue command', async () => {
let input = await $('.input')
await input.addValue('test')
await input.addValue(123)
value = await input.getValue()
assert(value === 'test123') // true
})
addValue.js
it('should demonstrate the addValue command', () => {
let input = $('.input')
input.addValue('test')
input.addValue(123)
value = input.getValue()
assert(value === 'test123') // true
})
caution
Synchronous Mode will depcrecated with Node.js v16. With an update to the underlying Chromium version it became technically impossible to provide the same synchronous behavior. We recommend to start transition to asynchronous command execution. For more information, see our RFC.