Appium on Android - SendKeys to EditText also types default text
After a lot of searching, I found that this is really a bug in Appium v 1.2.2:
https://discuss.appium.io/t/android-appium-1-2-2-sendkeys-issue-with-hinted-edit-text/309
Hopefully, as it is said there, it will be fixed in version 1.2.3.
Thanks for all your help!
Problem is you are using sendKeyEvent(67) only one time and that too at no proper place. What you have to do is first set your cursor at the end of the Text in Login field and then keep deleting each alphabet one by one until no more text is left in the field.
Eg: Try something like this
WebElement login = textFieldsList.get(0);// Get the webelement where text is to be entered string str = login.Text;// it will store the Text already written in login field int textLength = str.Length;// find the lenght of the text that is to be removed int x = login.Location.X +(textLength * 40); // int y = login.Location.Y;// TouchAction action = new TouchAction(driver);// TouchAction class is defined in appium library action.Tap(testObject, x, y);// for (int delete = 0; delete < str.Length; delete++) { rm.KeyEvent(67); } }
Hope it helps..
You're looking for
MobileElement textfield = driver.findElement(By.however(value))textfield.setValue('foo')
I haven't tested that function on Android, but it was built because textfield.sendKeys
is unreliable on iOS/Instruments.
You could also try textfield.click()
, textfield.clear()
, and then textfield.sendKeys('foo')
You'll need the Appium java-client