I\'m trying to type some text inside an EditText:
public void testSearch() {
onView(withId(R.id.titleInput)).perform(typeText(\"Engineer\"));
Same issue resolved with the following:
editText.perform(scrollTo(), click(), clearText(), typeText(myInput), closeSoftKeyboard())
Interestingly, I only ever had a problem when my machine was working hard.
I fixed this issue by setting layout_height="wrap_content"
on the View I wanted to click()
. Maybe it can help someone here.
If you're using Genymotion, you may need to switch the default keyboard in Genymotion Configuration (it's an app on the emulator).
NOTE: These changes do not persist after you close the emulator. You will need to set this every time you start the emulator.
Adding closeSoftKeyboard()
after typeText()
worked for me.
CODE:
onView(withId(R.id.editTextUserInput))
.perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
This is how it is documented in the Android docs.
Looks like I figured out the issue. It had to do with hardware vs software keyboard.
For Emulators:
Go to Settings -> Language & Input -> switch the Default Input to Sample Soft Keyboard.
For Phones:
Install a software keyboard from the Play store and switch to it. It appears that the native keyboards of some phones do not work.
It works now.
If the EditText does not has the focus yet, you should click on it first. If this solves your problem, then there is no bug.
onView(withId(R.id.titleInput)).perform(click()).perform(typeText("Engineer"));