getValue
Get the value of a <textarea>
, <select>
or text <input>
found by given selector.
If multiple elements are found via the given selector, an array of values is returned instead.
For input with checkbox or radio type use isSelected.
Usage
$(selector).getValue()
Examples
- Asynchronous Mode
- Synchronous Mode
index.html
<input type="text" value="John Doe" id="username">
getValue.js
it('should demonstrate the getValue command', async () => {
const inputUser = await $('#username');
const value = await inputUser.getValue();
console.log(value); // outputs: "John Doe"
});
index.html
<input type="text" value="John Doe" id="username">
getValue.js
it('should demonstrate the getValue command', () => {
const inputUser = $('#username');
const value = inputUser.getValue();
console.log(value); // outputs: "John Doe"
});
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.