I would stub out the dependency so that you can control your test environment, i.e. If you feed in 3 items, you should expect that three items are displayed. You can check this with the custom action by nenick How to count RecyclerView items with Espresso
public class CustomRecyclerViewAssertions {
//Asserts the number of items in a RecyclerView
public static ViewAssertion AssertItemCount(final int expectedCount) {
return new ViewAssertion() {
@Override
public void check(View view, NoMatchingViewException noViewFoundException) {
if (noViewFoundException != null) {
throw noViewFoundException;
}
RecyclerView recyclerView = (RecyclerView) view;
RecyclerView.Adapter adapter = recyclerView.getAdapter();
assertThat(adapter.getItemCount(), is(expectedCount));
}
};
}
}
which is called by using
onView(withId(R.id.recyclerView)).check(new RecyclerViewItemCountAssertion(3));
Once you know how many items are present, you can use:
onView(withId(R.id.recyclerView)).perform(
actionOnItemAtPosition<RecyclerView.ViewHolder>(1, click()))
As the recyclerView is showing multiple instances of the same view, I wouldn't waste time duplicating code to click each item