sendKeys() duplicating text and inconsistent behaviour


#1

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.isDisplayed();
email.click();
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]@email.com

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

I have tried hiding keyboard:
driver.hideKeyboard();

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


#2

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


#3

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.


#4

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?


#5

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?


#6

You can refer this article.


#7

too old server version?


#8

this solved the issue - thanks!!


#10

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”); ??

Thanks!!

@mykola-mokhnach @Suram_Sridhar_Reddy