sendKeys() method doesn't clean a pre filled text on text field (native android app)

sendKeys() method doesn’t clean a pre filled text on text field, instead it appends to it

will be fixed in appium v1.2.3 (not yet released)

Hi @bootstraponline,
I am using appium v. 1.3.4. Send keys on editText of Android (native app) deletes the former text. Now- if the former text was a hint, I would agree this is a correct behavior. But it is not.
So in my mind, this “feature” is actually a bug, in my opinion.
What do you think?
Is there a way for me to add text to this textbox?


Oh, sorry I forgot this is an intended feature. The send_keys implementation will delete the former text according to the official selenium spec. To append, grab the value of the existing text and include that when you invoke send_keys.

element.send_keys element.text + " some new text"

Well, it is a problem, because the webElement we are refering to is like the “to” field on any mailing application. It means that it is not plain text.
Once I enter the user name and choose it, it becomes something special, so grabing the text and appending will not do any good…
And I know in iOS send keys does not cause these problems…
Any other workaround? Maybe we can implement appendKeys method, that will not delete what already exists in the element, but rather places the cursor at the end of the text and send keys from there?

@ShiranDadon We had a method that did just that, called setText. I recommend opening a new issue on GitHub that explains this use case. I agree that appium should add a new method to cover this situation (in fact we had one in the past before it was removed). Let me know when the issue is opened and I’ll upgrade it to a feature request.

I also pulled the code, to see if I can create a patch for myself, but I can’t seem to open the project well on intelliJ :confused:
If you have a link that explains how to configure a development environment for appium, that will be great!