0

The standard way of triggering key event could look like this:

onView(allOf(withId(R.id.edit_text), isDisplayed())).perform(ViewActions.pressKey(KeyEvent.KEYCODE_0));

What to do if there is no target view( edit_text ) but there is custom Keyboard with just listener setOnKeyboardActionListener?

eleven
  • 6,779
  • 2
  • 32
  • 52

1 Answers1

0

For me it worked to set the custom android.inputmethodservice.KeyboardView to the withID method, and to using the pressKey method with KeyEvent.KEYCODE_NUMPAD_0 instead of KEYCODE_0:

onView(allOf(withId(R.id.keyboardview), isDisplayed()))
    .perform(pressKey(KeyEvent.KEYCODE_NUMPAD_0));
vitorefo
  • 21
  • 4