Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android: Click on Search icon on the keyboard - PressKeyCode is not working #265

Closed
email2vimalraj opened this issue Nov 6, 2015 · 7 comments

Comments

@email2vimalraj
Copy link
Contributor

commented Nov 6, 2015

In Android on my application, I've a Search icon on the keyboard which will be tapped by the user once when the user sends any value to the text field.

To automate this, I've tried the following:

driver.pressKeyCode(AndroidKeyCode.KEYCODE_ENTER);

and this:

driver.pressKeyCode(AndroidKeyCode.KEYCODE_SEARCH);

Both are not working. Then I was going through the code written by the developer and came across this:

@OnEditorAction(R.id.etSearchView)
protected boolean onSearchClicked(int actionId) {
    if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH || actionId == KeyEvent.KEYCODE_ENTER) {
        // Do search   
    }
}

while debugging, the actionId is 3 which is EditorInfo.IME_ACTION_SEARCH. So the KeyEvent is never been called. How do we handle this situation? I don't think the java-client has any capability for EditorInfo actions, do we?

@TikhomirovSergey

This comment has been minimized.

Copy link
Member

commented Nov 6, 2015

Hi @email2vimalraj
Which server version do you use?
The same issue was reported and closed: #257

@email2vimalraj

This comment has been minimized.

Copy link
Contributor Author

commented Nov 8, 2015

I use appium 1.4.13. Do you want me to raise this issue on the appium server?

@TikhomirovSergey

This comment has been minimized.

Copy link
Member

commented Nov 9, 2015

Yep. I think it is something wrong on the server side. But I suggest you to keep this issue opened to avoid the report duplication.

It is probably this issue: appium/appium#5162
If you think that you faced another problem please report it in details here
https://github.com/appium/appium/issues

@abourdon

This comment has been minimized.

Copy link

commented Apr 4, 2017

Hi guys, any news for this one?

@mukund-billa

This comment has been minimized.

Copy link

commented May 25, 2017

Hi,

Do we have any updates on the same, i am also facing the same issue during my test. Any workaround will be appreciated.

@SrinivasanTarget

This comment has been minimized.

Copy link
Member

commented Sep 25, 2017

Closing this due to inactivity

@jarod-legault

This comment has been minimized.

Copy link

commented May 16, 2019

This solution in JavaScript 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.