.clearText()
Wipes the contents of a text element.
Usage
element(matcher).clearText()
Returns
Element
: A new element to avoid mutation and allow function chaining.
Support
Platform | Supported |
---|---|
iOS | Yes |
Android | Yes |
Web | Yes |
Examples
Clear text input:
const { element, by, expect } = require("appdriver");
(async () => {
const $input = await element(by.label("text-input"))
.clearText();
await expect($input).toHaveValue("");
})();
Known Issues
- iOS simulators fail to clear text when the hardware keyboard is connected. Ensure
Hardware > Keyboard > Connect Hardware Keyboard
is unchecked. - Inputs fail to clear when using Xcode 11.x and iOS 12.x and below: (GitHub issue).