sendKeys() duplicating text and inconsistent behaviour

I am working on a framework and need to log in to the app, hence wanting to sendKeys to the email and password fields:
public void enterLoginEmail() {
WebElement email = driver.findElement(MobileBy.AccessibilityId(“emailAddress”));
email.sendKeys("[email protected]");

But the behaviour is inconsistent - with the most common result being the correct text being typed, then somehow a right click and copy the field, then it deletes the field completely, and finally will paste the original text twice. So in the end the field looks:
[email protected]

I have tried putting capabilities:
capability.setCapability(“unicodeKeyboard”, false);
capability.setCapability(“resetKeyboard”, false);

I have tried hiding keyboard:

I have tried adding +"\n" after the email text:
email.sendKeys("[email protected]" + “\n”);

I have tried stopping predicative text.

None of the above has helped - would anyone have an idea??

Note: Using Java 1.8.0_201 on Intellij, UIAutomator2, and Android emulator

This field probably has some additional verification helpers, which prevent sendText API from working properly. Try as a workaround, since it generates keystrokes in the manner, which is closer to the native input

If you taking about Android, then adb is the easy way to avoid this issue.
Use adb command to send text.
Example: adb shell input text "[email protected]"

If you have any unicode related stuff then refer below method.

Hey thanks for this - I tried it and received this error on the a.perform() line:
INFO: HTTP Status: ‘404’ -> incorrect JSON status mapping for ‘unknown method’ (405 expected)
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented

I double checked i was using UIAutomator2, and I am… :confused: ideas?

Hi - i’m not quite sure how to implement adb commands into my java tests - so they run automatically without needing my input. Have you ever needed to do this?

You can refer this article.

1 Like

too old server version?

this solved the issue - thanks!!

1 Like

Hey guys -
I’m having the similar issue for iOS.
Is there an iOS version of
ProcessBuilder pb = new ProcessBuilder(“adb”, “shell”, “input”, “text”, “blablabla”); ??


@mykola-mokhnach @Suram_Sridhar_Reddy

1 Like

We don’t have such command for IOS device. Please share the issue which you are facing in IOS

hi, i have the same problem, did you get any solution?
the problem that I have in iOS, is that with sendkeys, it writes the string 2 times