Unable to tap 'search' button on Android softKeyboard

Please help me to enter search button after entering some text on search field in Android application


Please use Android Drivers to tap on Search button co-ordinates.

driver.tap(1, 710, 1260, 1);

Here 710, 1260 are co-ordinates lying on my Search button. Change them to your required co-ordinates to tap on Search.

As of now I am tapping on Search by co-ordinates. Still not able to use sendkeycode()

driver.tap(1, 710, 1260, 1);


use this option to click Soft keyboard search key icon


1 Like

Is that one working with the ‘search’ key?
I have another workaround if you do not want to tap a xy-location (like me, because I use different devices/sims).

I have a step: I set (.) as value on the (.) (.*) — (value, id, type)
I always save the value in the World object in the property lastValue (so I overwrite it every time I use this step).
And I always save the id in the World object in the property lastId (so I overwrite it every time I use this step).

.waitForElementById(id, this.TIME_OUT, this.POLLING_TIME)

Then I have step: I send key event (.*) — (code)
I check if its the code for the search button. If it is then I set the value again but with an enter behind the value. It cost you a bit more time but you probably don’t use the search key event a lot (because often there is a physical button).

.waitForElementById(this.lastId, this.TIME_OUT, this.POLLING_TIME)


The problem is still actual in appium 1.4 and it’s rather citical for us. We want to run out tests on different devices but we need to use coordinates because of this issue and it’s problem. We hoped that this issue would be fixed in 1.4 but it doesn’t.

1 Like

We have faced the same issue during our test script creation and resolved it successfully.
Initially when we create the script we used " driver.sendKeyEvent(66)" and even tried 84 for clicking on search button but it never worked.
Later after doing research we identified the below details,

In the application source when user tap on the search it is used “OnEditorActionListener” to identify the search key pressed and do action based on it, The function definition looks like below
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
– the condition and the action written inside this–

Unfortunately the keyevent we are sending will not capture through this listener, So we have added another listener and method to handle that case along with OnEditorActionListener , that is “OnKeyListener” and the method definition looks like below
public boolean onKey(View v, int keyCode, KeyEvent event)
– The condition to check for keycode 66 and 84 and if it is satisfied do the search action—
This will be used when we send the keyevent from the script and there is no impact on the manual search process.After this the search is working very fine without any issue.

Please note; we havent changed anything in our test script, only change made in the application soruce for search part.

You can check with your app developer to check this case.I hope this will help to resolve the issue.


Hello…you have said that you used coordinates to tap on search ,can you please tell me how exactly you did it??

Hi! we just found in Android Device Monitor the approximate coordinates of the search button and just tap on this coordinate with tap action. But as I mentioned before - this works only for exact device with exact screen size.

This is really annoying. I am not sure why Appium team is not taking this as priority issue. For many e-Commerce applications, this is basic functionality by searching for an item.

Tried all above options(except changing listener method specified by praveen) specified in the thread, but none helps.

Did you try like below,

If your text box xpath is //SearchTextEdit and search term is Hello


1 Like

As praveen said, this could be a listener issue.

If the application is having valid listener, then in most of the time “string+”\n"" should work.

But if it doesnt have proper listener, which may not succeed.

In my case, i am not sure what is wrong, but when i tried string+"\n" which navigates me to Home screen.

For now, this is a blocker issue for me.

For me driver.sendKeyEvent(66); is working

I getting an error, The method sendKeyEvent(int) is undefined for the type AndroidDriver,

I’ve got the same problem,then tried it the way you’ve provided.
And finally it worked out,wonderful!!!

1 Like

Hi Praveen, I am in a similar issue currently where my mobile app search bar opens mobile softkeyboard with search.
The above option you mentioned seems like a good way of solving my problem however I am not sure how to implement it.
I have a class which extends to Helper Class which has all these methods I am writing for clicking mobile device back button,home button etc.
DO I need to create the public boolean onEditorAction(TextView v, int actionId, KeyEvent event) methods in same class or is it an listener class which I need to create. Can you please send me the complete method code for my reference please.
Thanks in advance.


Try the solution from https://github.com/appium/java-client/issues/916

This solution in JavaScript using wd worked for me:

return driver.waitForElementById(<elementId>).type(<text to type>).click().execute( "mobile: performEditorAction", { "action": "search" } );

This allowed me to find a text field, input some text, and submit a search command (same as clicking the search icon in the keyboard). Of course, you have to replace <elementId> and <text to type> with the proper values. See http://appium.io/docs/en/commands/mobile-command/ for details on “mobile: performEditorAction”.


can you help with a Python-client solution please?

How can I do this with Python? It has been blocker for me