Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Espresso - typeText not working

I'm trying to type some text inside an EditText:


    public void testSearch() {
          onView(withId(R.id.titleInput)).perform(typeText("Engineer"));
          onView(withId(R.id.titleInput)).check(matches(withText("Engineer")));
    }

I see the EditText is getting focus, but nothing happens. No text is typed.
I tried this on a phone and an emulator - same result.

like image 694
Eduard Avatar asked Dec 07 '13 02:12

Eduard


1 Answers

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.

like image 90
Eduard Avatar answered Oct 26 '22 21:10

Eduard