# Unable to tap 'search' button on Android softKeyboard

**URL:** <https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598>\
**Category:** Issues/Bugs\
**Created:** [November 21, 2014, 10:49am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598 "2014-11-21T10:49:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![preetparikh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@preetparikh](https://discuss.appium.io/u/preetparikh)\
**Post date:** [November 21, 2014, 10:49am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/1 "2014-11-21T10:49:48Z")

</div>

Hello,

I am trying to type in a search box within my app and tap/click on search button(magnifying glass) on keyboard. But I am unable to click/tap on it. I have tried below things:

1. driver.sendKeyEvent(84);  
Appium says it successfully sent in the command but ‘search’ does not get tapped. Cursor remains in text box and results do not filter.

2. HashMap\<String, Integer\> swipeObject = new HashMap\<String, Integer\>();  
swipeObject.put(“keycode”, 84);  
((JavascriptExecutor ) driver).executeScript(“mobile: keyevent”, swipeObject);  
Appium says not yet implemented.

3. JavascriptExecutor jse = (JavascriptExecutor) driver1; jse.executeScript(“UIATarget.localTarget().frontMostApp().keyboard().buttons()[‘Done’].tap();”);  
Appium says not yet implemented.

4. driver.sendKeyEvent(AndroidKeyCode.ENTER, AndroidKeyMetastate.META\_FUNCTION\_ON);  
Appium says it successfully sent in the command but ‘search’ does not get tapped. Cursor remains in text box and results do not filter.

5. driver.sendKeyEvent(AndroidKeyCode.ENTER);  
Nothing happens

All other send key events works except ENTER, Search. I can use sendKeyEvent for alphabets, numbers, space etc.

I am using Ecllipse, AndroidDriver, AppiumDriver, TestNG, Appium(1.2.4.1), Samsung Galaxy Note 3.

Any help on this would be really helpful. I went through lot of Googling but till not successful tapping search key.

---

<div class="post-metadata">

**Author:** ![Sergey\_Kim](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@Sergey\_Kim](https://discuss.appium.io/u/Sergey_Kim)\
**Post date:** [November 26, 2014, 4:21pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/2 "2014-11-26T16:21:56Z")

</div>

I’m not sure about it, however I read the article wrote by a guy from Yandex and they’ve mentioned that they handled similar problem with tapping into coordinates. So you just need to calculate the coordinates of your magnifying glass and tap there. Hope it will help

---

<div class="post-metadata">

**Author:** ![preetparikh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@preetparikh](https://discuss.appium.io/u/preetparikh)\
**Post date:** [November 28, 2014, 12:23pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/3 "2014-11-28T12:23:09Z")

</div>

I already did that and that works. Thank you.  
But now that does not work when I change devices. The search button co-ordinates change for different screen size. Any work around?

---

<div class="post-metadata">

**Author:** ![Sergey\_Kim](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e9c0ed/32.png) [@Sergey\_Kim](https://discuss.appium.io/u/Sergey_Kim)\
**Post date:** [November 28, 2014, 12:55pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/4 "2014-11-28T12:55:58Z")

</div>

Is there a chance to calculate coordinates from scree size? I mean like have a button coordinates as a i.e. screen height \* 0.23 and screen width \* 0.35?

---

<div class="post-metadata">

**Author:** ![preetparikh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@preetparikh](https://discuss.appium.io/u/preetparikh)\
**Post date:** [November 28, 2014, 1:13pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/5 "2014-11-28T13:13:57Z")

</div>

Yes I guess that an be done. But it would be great if Appium starts sending in ‘SEARCH’ key soon. 😄

Thanks for the help once again.

---

<div class="post-metadata">

**Author:** ![rickdehoop](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@rickdehoop](https://discuss.appium.io/u/rickdehoop)\
**Post date:** [January 14, 2015, 2:06pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/6 "2015-01-14T14:06:18Z")

</div>

any updates on this ?

---

<div class="post-metadata">

**Author:** ![Fayizkc](https://discuss.appium.io/user_avatar/discuss.appium.io/fayizkc/32/11081_2.png) [@Fayizkc](https://discuss.appium.io/u/Fayizkc)\
**Post date:** [January 19, 2015, 12:05pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/7 "2015-01-19T12:05:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![preetparikh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@preetparikh](https://discuss.appium.io/u/preetparikh)\
**Post date:** [January 19, 2015, 12:46pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/8 "2015-01-19T12:46:42Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![preetparikh](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/4491bb/32.png) [@preetparikh](https://discuss.appium.io/u/preetparikh)\
**Post date:** [January 19, 2015, 12:47pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/9 "2015-01-19T12:47:49Z")

</div>

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

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

---

<div class="post-metadata">

**Author:** ![Jagatheskmp](https://discuss.appium.io/letter_avatar_proxy/v4/letter/j/6bbea6/32.png) [@Jagatheskmp](https://discuss.appium.io/u/Jagatheskmp)\
**Post date:** [January 19, 2015, 9:03pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/10 "2015-01-19T21:03:44Z")

</div>

Hi,

use this option to click Soft keyboard search key icon

driver.sendKeyEvent(66);

---

<div class="post-metadata">

**Author:** ![rickdehoop](https://discuss.appium.io/letter_avatar_proxy/v4/letter/r/db5fbb/32.png) [@rickdehoop](https://discuss.appium.io/u/rickdehoop)\
**Post date:** [January 20, 2015, 3:49pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/11 "2015-01-20T15:49:15Z")

</div>

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).

this.driver  
.waitForElementById(id, this.TIME\_OUT, this.POLLING\_TIME)  
.setText(value)  
.nodeify(next);

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).

this.driver  
.waitForElementById(this.lastId, this.TIME\_OUT, this.POLLING\_TIME)  
.setText(this.lastValue+’\n’)  
.nodeify(next);

---

<div class="post-metadata">

**Author:** ![kateogar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kateogar](https://discuss.appium.io/u/kateogar)\
**Post date:** [June 10, 2015, 5:44pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/12 "2015-06-10T17:44:34Z")

</div>

Hi!

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.

---

<div class="post-metadata">

**Author:** ![praveentp009](https://discuss.appium.io/letter_avatar_proxy/v4/letter/p/b38774/32.png) [@praveentp009](https://discuss.appium.io/u/praveentp009)\
**Post date:** [July 7, 2015, 6:18pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/13 "2015-07-07T18:18:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bindu](https://discuss.appium.io/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@bindu](https://discuss.appium.io/u/bindu)\
**Post date:** [November 7, 2015, 11:13am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/14 "2015-11-07T11:13:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kateogar](https://discuss.appium.io/letter_avatar_proxy/v4/letter/k/9f8e36/32.png) [@kateogar](https://discuss.appium.io/u/kateogar)\
**Post date:** [November 12, 2015, 8:54pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/15 "2015-11-12T20:54:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![UD](https://discuss.appium.io/letter_avatar_proxy/v4/letter/u/3be4f8/32.png) [@UD](https://discuss.appium.io/u/UD)\
**Post date:** [February 19, 2016, 8:08am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/16 "2016-02-19T08:08:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dasuner](https://discuss.appium.io/user_avatar/discuss.appium.io/dasuner/32/1835_2.png) [@dasuner](https://discuss.appium.io/u/dasuner)\
**Post date:** [February 22, 2016, 6:40am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/17 "2016-02-22T06:40:42Z")

</div>

@preetparikh  
Did you try like below,

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

driver.findElement(By.xpath("//SearchTextEdit")).sendKeys(“Hello”+"\n");

---

<div class="post-metadata">

**Author:** ![UD](https://discuss.appium.io/letter_avatar_proxy/v4/letter/u/3be4f8/32.png) [@UD](https://discuss.appium.io/u/UD)\
**Post date:** [February 24, 2016, 7:21am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/18 "2016-02-24T07:21:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Venkatesh\_Sunfra](https://discuss.appium.io/letter_avatar_proxy/v4/letter/v/aeb1de/32.png) [@Venkatesh\_Sunfra](https://discuss.appium.io/u/Venkatesh_Sunfra)\
**Post date:** [October 5, 2016, 11:54am UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/19 "2016-10-05T11:54:14Z")

</div>

For me driver.sendKeyEvent(66); is working

---

<div class="post-metadata">

**Author:** ![SP](https://discuss.appium.io/letter_avatar_proxy/v4/letter/s/e9bcb4/32.png) [@SP](https://discuss.appium.io/u/SP)\
**Post date:** [April 3, 2017, 5:47pm UTC](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598/20 "2017-04-03T17:47:04Z")

</div>

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

[Next page](https://discuss.appium.io/t/unable-to-tap-search-button-on-android-softkeyboard/1598.md?page=2)
