onData(anything()) .inAdapterView(withId(R.id.recyclerview)) .atPosition(position) .onChildView(withId(R.id.minus)) .perform(click()); 

C ListView worked norms. Replaced ListView with RecyclerView gives an error android.support.test.espresso.PerformException: Error performing 'load adapter data' on view 'with id:

  • at least because there is no AdapterView in RecyclerView - georgehardcore

2 answers 2

Figured out

  onView(withId(R.id.recyclerview)) .perform(RecyclerViewActions.actionOnItemAtPosition(position, clickChildViewWithId(R.id.minus))); public static ViewAction clickChildViewWithId(final int id) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return null; } @Override public String getDescription() { return "Click on a child view with specified id."; } @Override public void perform(UiController uiController, View view) { View v = view.findViewById(id); v.performClick(); } }; } 

    In this implementation, recyclerView does not correctly "presence" onData , since they do not work together. onData - designed for AdapterViews like ListView, GridView, Spinner, etc. I see that you understand the answer , but for reinforcement and for future readers of this question I will attach off-documentation , which will tell you how to start.