Appearance
I.fill()
Fill a text input field with a specific value.
Any existing value in the input field will be cleared and replaced with the given value.
This works for <input> elements that accept text input and <textarea> elements.
INFO
I.fill() clears an existing value in the input field and replaces it with the given value. To insert text instead, use I.type().
I.fill() only targets <input> and <textarea> elements. To interact with rich text editors or contenteditable elements, use I.type().
Usage
js
I.fill(element: string, value: string)Parameters
| Parameter | Type | Description |
|---|---|---|
element | string | Text input element to target — by visible text, CSS or XPath selector |
value | string | Value to fill into the field |
Examples
Fill a field by visible text
js
I.fill("Email", "[email protected]");Targets the input field labeled Email and fills it with the specified value.
This targets an element that best matches the text "Email" (case-insensitive), based on:
- associated
<label>elements - descriptive attributes such as
aria-label,title,alt-text - the text content of the element, including the input
placeholderandvalue - the
nameattribute - adjacent text
Fill a field using CSS
js
I.fill("#email-input", "[email protected]")Targets the input element matching the CSS selector #email-input.
Fill a field using XPath
js
I.fill("//*[@name='email']", "[email protected]")Targets the input element matching the XPath selector //*[@name='email'].
Clear a field
To clear an input field, fill it with an empty string:
js
I.fill("Email", "");Or use I.clear():
js
I.clear("Email");