Not able to Use sendKeys for Return or Enter (Also not working "string" + \n) appium 1.7.1

Hi,

(Platform: Android)

For a Text field, I’m using driver.sendKeys(“String” + “\n”) to send the string and enter but it is not working at all in the appium version 1.7.1.
Even I tried with sendKeys(Keys.RETURN)
And, Keys.TAB
And, Keys.ENTER

When I’m using above Keys, appium enters an unwanted/ unrecognized symbol in the text field.

These were working perfectly in Appium 1.5.4

I’m not using the device keyboard(capabilities.setCapability(“resetKeyboard”, true);).

Logs for driver.sendKeys(“String” + “\n”):

[JSONWP Proxy] Proxying [POST /element/2ef04337-1544-403d-b00a-7e35915e2d7b/value] to [POST http://localhost:8200/wd/hub/session/e937e35d-b421-44eb-ab53-4d5e47838e89/element/2ef04337-1544-403d-b00a-7e35915e2d7b/value] with body: {“elementId”:“2ef04337-1544-403d-b00a-7e35915e2d7b”,“text”:“4\n”,“replace”:false,“unicodeKeyboard”:true}
[JSONWP Proxy] Got response with status 200: {“sessionId”:“e937e35d-b421-44eb-ab53-4d5e47838e89”,“status”:0,“value”:""}

Here status shows 200 but in the app, it doesn’t enter.

Logs for Keys.ENTER:
[JSONWP Proxy] Proxying [POST /element/ece8265a-88a9-4fa0-918c-03bcd00eb145/value] to [POST http://localhost:8200/wd/hub/session/5474d373-d875-4a6d-93b8-586bcd0b8d5a/element/ece8265a-88a9-4fa0-918c-03bcd00eb145/value] with body: {“elementId”:“ece8265a-88a9-4fa0-918c-03bcd00eb145”,“text”:“”,“replace”:false,“unicodeKeyboard”:true}
[JSONWP Proxy] Got response with status 200: {“sessionId”:“5474d373-d875-4a6d-93b8-586bcd0b8d5a”,“status”:0,“value”:""}
[MJSONWP] Responding to client with driver.setValue() result: “”

So question is, how can I send a String to the text field and enter it without using a keyboard

If anyone has ideas or workaround, please let me know.

Thanks!!!

See this in the logs, in the part of “\n” sending 

I had the same error months ago and tried everything.
This happened rarely on some applications: The way app developers receive the “Search” command does not match with how you generate the “Search” command. I’m guessing this is because app waits for specificly Android’s Search Bar’s search event. (I wish I could provide with links but I couldn’t find them anywhere)

I suggest the brute force approach by clicking search button from keyboard (with coordinates derived from screen size)
It works, saves you time and simulates the search bar usage correctly.

I’m sharing my search bar method for Android, in case you also can’t find any solution :slight_smile:

public void tapSearch() {
	Dimension d = driver.manage().window().getSize();
	int height = d.height;
	int width = d.width;
	int xCoor = (width * 91) / 100;
	int yCoor = (height * 96) / 100;
	driver.tap(1, xCoor, yCoor, 10);
}

Thanks for the help!!!

But I can’t use this (brute force approach by clicking search button from keyboard) because I’m using “capabilities.setCapability(“unicodeKeyboard”, true);” to hide the virtual keyboard.

Any other way around you have except brute force approach?

There is a pressKeyCode() approach?
I haven’t used Keys.RETURN but I have tried these, maybe it can help you if you haven’t tried key code approach yet?

I have fixed my code for this using double ‘’ backspace
I.e
driver.sendKeys(“String” + “double backspace ‘’”);

I have fixed my code for this using double ‘’ backspace
I.e
driver.sendKeys(“String” + “double backspace ‘’”);

u have added double backspace this text in the code.