UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

43 lines (40 loc) • 1.85 kB
import type { InputOptions } from '../../types.js'; /** * Send a sequence of key strokes to an element after the input has been cleared before. If the element doesn't need * to be cleared first then use [`addValue`](/docs/api/element/addValue). * * :::info * * If you like to use special characters, e.g. to copy and paste a value from one input to another, use the * [`keys`](/docs/api/browser/keys) command with the [`Key`](/docs/api/modules#key) object. * * ::: * * Inputs of type `range`, `date`, `datetime-local`, `month`, `week`, `time` and `color` don't take key strokes * as typed text. For them `setValue` sets the value directly and fires the `input` and `change` events, as * picking a value with the mouse does. Pass the value in the input's own format, e.g. `2026-10-04` for a date * or `14:30` for a time. The browser corrects values that don't fit, like a range input does with a value * between two steps; read the result with [`getValue`](/docs/api/element/getValue). * * <example> :setValue.js it('should set value for a certain element', async () => { const input = await $('.input'); await input.setValue('test') await input.setValue(123) console.log(await input.getValue()); // outputs: '123' }); it('should set the value of a date input', async () => { const input = await $('input[type="date"]'); await input.setValue('2026-10-04') console.log(await input.getValue()); // outputs: '2026-10-04' }); * </example> * * @alias element.setValue * @param {string|number} value value to be added * @param {InputOptions} additional options, exclusive to Webdriverio * */ export declare function setValue(this: WebdriverIO.Element, value: string | number, options?: InputOptions): Promise<void>; //# sourceMappingURL=setValue.d.ts.map