Currently there is one way to do so is sending the key event of the āEnterā key.
You cant get the android keys as element because UI Automator does not detects the buttons of the keyboard.
One Work Around to do exactly what you mentioned is presize tap on the āDoneā button, but it wonāt be generic.(Avoid it)
Using the key event is the best and recommended way.
@pr4bh4sh, why not using dirver.keyevent(84) for KEYCODE_SEARCH. I think itās very simple way.
WRT āDoneā or āOKā key, I donāt see any android keyevents for it link
which really amazes me
Indeed thatās the simplest way.( What i suggested were workaround as the author of this post was looking for the possible way to actually tap on the key, which is not possible for android)
Yes there arenāt any Key code for āDoneā, to achieve this i usually send enterās key code
No there arenāt any specific key code for Done/OK/Next key. For simulating those we need to send the metastate along with the keycode of āEnterā key.
driver.sendKeyEvent(key, metastate);
For sending the Next/Done key metastate code is 16.
If that not working we can send the KEYCODE_DPAD_DOWN (for Next).
And these are just workaround if the thing are not working as expected.