RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

Unable to perform a search operation using the device soft keyboard search icon. #653

Closed renas closed 9 years ago

renas commented 9 years ago

From Zaid.I.M...@gmail.com on January 28, 2014 07:09:01

Hi Renas,

We are testing an Hybrid application. The scenario is we have a Native text box (which is AutoCompleteTextView) where in we send the keyword to search along with this there is a cancel button .

As soon as there is focus on the text box the device soft keyboard pops up. We use this.solo.enterText(searchBarAutoCompleteTextBox, keyword); to send in the keyword And now we want to click the search icon of the device soft keyboard , so we used the following different methods: 1.this.solo.sendKey(KeyEvent.KEYCODE_SEARCH); 2.this.solo.sendKey(EditorInfo.IME_ACTION_SEARCH); 3.this.solo.sendKey(Keyboard.KEYCODE_DONE); 4.this.solo.sendKey(Keyboard.KEYCODE_ENTER); 5.this.solo.sendKey(Solo.ENTER);

but none of the above methods helped us.

Can you please provide us your inputs on how we can go about it. This is a major blocker for us.

Would appreciate if we get a resolution for this very soon.

Thanks, Zaid

Original issue: http://code.google.com/p/robotium/issues/detail?id=574

renas commented 9 years ago

From renasr...@gmail.com on January 28, 2014 21:06:20

The soft keyboard is not part of the app you're testing and therefore you are not allowed to interact with it. This is a limitation in the Android platform. You could try if solo. pressSoftKeyboardNextButton() will work for you.

Status: Invalid
Owner: renasr...@gmail.com

renas commented 9 years ago

From Zaid.I.M...@gmail.com on January 29, 2014 03:18:12

Well thanks for the above comments. solo.pressSoftKeyboardNextButton() did not work out. But this method gave us the clue on how we can press the search icon. What we did is: we created an object of AutoCompleteTextView by getting its id in searchBarAutoCompleteTextBox i.e., AutoCompleteTextView searchBarAutoCompleteTextBox = this.solo.getView(package.id.ID_OF_THE_TEXTBOX); AutoCompleteTextView.onEditorAction(EditorInfo.IME_ACTION_SEARCH); // this line of code could perform a search operation for us.

Thanks, Zaid

renas commented 9 years ago

From renasr...@gmail.com on January 29, 2014 03:21:01

Great to hear. Thanks for the feedback. We'll see if we can add a method like this in the next release.

renas commented 9 years ago

From Zaid.I.M...@gmail.com on January 29, 2014 03:37:35

My pleasure . And great thanks to you, Renas.