如何使用Espresso在Android软键上按“编辑器操作”键?我尝试过:
onView(withId(R.id.edToNumber)).perform(typeText("MDO158"),ViewActions.pressKey(KeyEvent.ACTION_UP), closeSoftKeyboard())
答案 0 :(得分:0)
要从特定EditText的键盘上单击ActionDone button
,可以使用以下代码完成操作:
onView(withId(R.id.edToNumber)).perform(typeText("MDO158");
onView(withId(R.id.edToNumber)).perform(pressImeActionButton());
注意:
pressImeActionButton()
(不是专门用于单击键盘上的ActionDone button
,它会单击键盘上的任何ActionButton
,例如ActionDone
,ActionSearch
,{ {1}}等
(可选),您可以使用以下代码关闭特定EditText的键盘,而无需单击ActionDone按钮:
ActionNext
答案 1 :(得分:0)
您可以使用以下代码
onView(withId(R.id.edToNumber))
.perform(typeText("some"), pressImeActionButton());