Appium : Clear a field

0
0

I have my login screen in app now. Each time the app is launched in screen the mobile number is pre filled with the older text.

I just want to know I have tried:

WebElement mob = driver.findElement(By.name("Mobile Number"));
mob.clear // Not working

I have tried :

String Mobile
mob="";

but still it cannot delete the pre filled text.

I am trying to automate my android app using appium, please help me with this.

  • You must to post comments
0
0

It is definitely not efficient, could be improved and there’s probably a better way…
But, using adb’s shell input key event codes I simply called “dpad right” to move the cursor all the way to the right. Once there, send the key code “DEL” to start deleting all the way back…
So… two for-loops. This was mainly used for short texts:

public void cleatTextFully(WebElement element) {
int stringLength = element.getText().length();
for (int i = 0; i < stringLength; i++) {
mDriver.sendKeyEvent(22); // "KEYCODE_DPAD_RIGHT"
}
for (int i = 0; i < stringLength; i++) {
mDriver.sendKeyEvent(67); // "KEYCODE_DEL"
}
}

mDriver is the AppiumDriver instance.
Hope this helps some what.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website