Espresso AutoCompleteTextView click

Issue

So I recently started messing around with Espresso in one of my existing Android projects.

Everything went pretty decently, until I came to find AutoCompleteTextView in my program. I don’t seem to understand how to properly click the first thing in the autocomplete list. I’m actually not even sure which to use, onView() or onData() in this instance.

Solution

So i finally figured it out, thanks to this previous question:
Testing autocomplete textview using espresso tool

Ill just post my version of it for people who might use it in future.

    onData(instanceOf("Whatever your arrayadapter contains".class)).inRoot(RootMatchers.withDecorView(not(is(mActivityRule.getActivity().getWindow().getDecorView())))).perform(ViewActions.click());

Answered By – user3050720

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *