Alexandr
Alexandr

Reputation: 3969

How to perform actionDone event of EditText with Espresso

Question in the title.

I tried something like:

    onView(withId(R.id.search_edit_text))
            .perform(typeText("some"), pressKey(KeyEvent.KEYCODE_ENTER));

But it doesn't work. Keyboard is still shown and TextView.OnEditorActionListener not called. Any ideas?

Upvotes: 8

Views: 3159

Answers (2)

Anh Duy
Anh Duy

Reputation: 1183

I used KEYCODE_BACK and it works well. KEYCODE_ENTER not working on my device SAMSUNG A70

onView(withId(R.id.edit_text).perform(ViewActions.pressKey(KeyEvent.KEYCODE_BACK))

Upvotes: 0

liminal
liminal

Reputation: 1164

Try

onView(withId(R.id.search_edit_text))
        .perform(typeText("some"), pressImeActionButton());

Upvotes: 21

Related Questions