I have a heterogeneous recycler view and I am trying to scroll it to item at position 30. My test is passing but I cannot see the screen actually scrolling.
onView(withId(R.id.content_view))
.perform(RecyclerViewActions.scrollToPosition(30));
This is what I am doing to scroll.
Use scrollToHolder()
:
onView(withId(R.id.recyclerViewId))
.perform(scrollToHolder(viewHolderMatcher(some_parameter_to_match)));
where viewHolderMatcher(some_parameter_to_match)
returns Matcher<RecyclerView.ViewHolder>
i.e. the position of the holder/item in the RecyclerView.
Or only by position:
onView(withId(rvLayoutId))
.perform(actionOnItemAtPosition(256, scrollTo()));
last one is from here.