Hi Appium Dev team,
I have a suggestion about improving the performance or reducing the time of input using the sendKeys() function. There are lots of issues post are coming in this forum for sendKeys() function.
From what i understand the behavior of sendKeys() function is, It takes the parameter passed in it and sends the text over the adb shell (I’m not sure if that way it’s happening?)
adb shell input text "parameter"
My idea is that rather then sending the data to the input field directly
Copy the data in clipboard of the device.
Now paste the data from clipboard.
If it’s possible to achieve this, the length of the string would be irrelevant (i hope).
While I’m working on doing this using Java, I request everyone to give your thoughts on this idea. @jonahss@Hassan_Radi@bootstraponline@jlipps@SergeyTichomirov please look into this if it’s feasible.
As far as I can tell, most of the time taken while sending keys is wasted in clearing any pre-filled text or any hint text. The sendkeys function sure needs some improvements to be as stable as its Selendroid’s counterpart.
Your suggestion sounds logic and I think it might work. We just need to try it out and see if it can handle all of the special cases that are causing a lot of bugs right now…
Interesting idea. SendKeys should simulate typing individual keys on the keyboard, but maybe we could use this approach for setValue. What does @bootstraponline think?
Is send_keys working for you guys on iOS using Xcode6?
It only works for me if I have test in the textfields by default.
But, if I clear it out first, it does not work.
I have pressed cmd+k and tried to implement the soft keyboard several times.
I imagine that I am doing something wrong on my side, but I can not figure out what.
The problem with send keys on Android is we can’t reliably clear the textfield using uiautomator. The proper fix for this is rearchitecting android support to use an instrumentation(via Espresso)/uiautomation hybrid so we can call instrumentation methods that are much less flaky than uiautomator.
adb shell input text or messing with the clipboard are ways to input text. It doesn’t solve the problem of clearing the textfields which is what sendKeys must do according to the spec.
Is there any alternative, faster way than sendKeys, to populate text field in android? I tried clicking element and performing sendKeyEvent multiple times, to send every key separately, and it is faster with small amount of characters, it doesn’t clear textbox, but I don’t need that. Do you know some better way? It would be useful to add flag for sendKeys method to clear/don’t clear text before input.
I now use directly adb command for input text, ie have method that clicks on desired text field and calls adb input text command, I have flag for clearing text field, if true I call clear method, which is not perfect because if you have textbox that moves on click clear() method will fail, so I need to click on textbox even before clear method.
public void sendKeys(String keysToSend, boolean clear) {
if (clear && text != null && keysToSend.equals(text))
return;
if (clear) {
click();
getElement().clear();
}
click();
AdbUtil.inputText(keysToSend);
text = keysToSend;
}