Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to presskey editor action on Espresso

How do you press the Editor Action key on Android softkey using Espresso? I tried:

onView(withId(R.id.edToNumber)).perform(typeText("MDO158"),ViewActions.pressKey(KeyEvent.ACTION_UP), closeSoftKeyboard())

like image 326
Sendi Avatar asked Oct 18 '25 06:10

Sendi


1 Answers

To click the ActionDone button from the keyboard of a Specific EditText, you could done by using this code:

onView(withId(R.id.edToNumber)).perform(typeText("MDO158");
onView(withId(R.id.edToNumber)).perform(pressImeActionButton());

Note:

pressImeActionButton() not specifically used for click the ActionDone button from the keyboard, it click whatever ActionButton that the keyboard consist such as ActionDone, ActionSearch, ActionNext, etc.

Optionally, you can close the keyboard of a Specific EditText without click the ActionDone button by using this code:

onView(withId(R.id.edToNumber)).perform(typeText("MDO158");
onView(withId(R.id.edToNumber)).perform(closeSoftKeyboard());
like image 163
I am a Student Avatar answered Oct 19 '25 20:10

I am a Student