I’m using the Java code below to clear a pre-filled textfield but it’s taking way too long (about 5-7 seconds just to clear the field). My script is required to do this about a hundred times so it will take up lots of valuable time. Is there any way to speed this up?
For those who are interested, I found a way to significantly speed up the clearing of a textfield by selecting the entire text and pressing the backspace using the code below.
public static void clearField(AndroidDriver driver, By by) {
TouchAction touchaction = new TouchAction(driver);
touchaction.press(driver.findElement(by)).longPress(driver.findElement(by));
touchaction.perform();
driver.pressKeyCode(AndroidKeyCode.BACKSPACE);
}
I would suggest to perform sendkeys and provide blank value into it. It will work faster. Make sure that you have the latest appium (Atleast 1.4.16, which I am using currently).