I have a case where there are several instances of an element, and I want to count them. My view count is as follows:
public static ViewInteraction onTestPanelView(){
return onView(allOf(withId(R.id.myId), isDisplayed()));
}
With a match for the view, I get the following error:
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException: '(with identifier: is <2131427517> and appears on the user screen)' corresponds to several views in the hierarchy. The task views are marked with "**** MATCHES ****" below.
This is correct because I have multiple instances of elements with the same identifier (R.id.myId). I want to write a method that returns me the number of views matching my criteria. Please note: they are not in adapter mode.
source
share