I am using Espresso to test an app with several AutoCompleteTextViews. For one particular test, the autocomplete popup appears, but I want to just ignore it and move to the next TextView
. How can I do this? My ideas are to either simulate a "Back" press or simulate a tap in the popup.
Update:
I am attempting the following to click on the autocomplete popup:
onView(withId(R.id.brand_text))
.perform(scrollTo(), typeText(card.getBrand()));
onData(allOf(is(instanceOf(String.class)), is(card.getBrand())))
.inRoot(isPlatformPopup())
.perform(click());
onView(withId(R.id.brand_text))
.check(matches(withText(card.getBrand())));
Now the problem is that in some cases, the text entered doesn't have any autocomplete matches so no popup appears. How do I conditionally perform the click depending on whether or not a view is matched?