Espresso finding row in RecyclerView that could be off screen


I have a RecyclerView which could contain any number of items. I need to be able to get a single row from that list so i can check its contents or click/long click on that row.

I am struggling greatly to figure out how to do this as unlike ListView’s “onData” there is no built in functionality to scroll through the RecyclerView to find the row. It appears that with RecyclerView if the view is not actually ON SCREEN you can not verify that rows UI.

In the examples I have seen they are using the number of items in the list to scroll to each row. However I do not know in advance how many rows my list has as the number is not fixed.

This solution looked very promising, but that assumes you know the items in your list to pass into the espresso objects which is not applicable to me.

This example also assumes it knows which rows are off screen

Likewise this example knows which row to move to

I need to do something like


where “findRowWhichHasText” does something like

  • find the number of items in the list

  • scroll to each one in turn (scrollToPosition(i) )

  • check if that row has the item I want. Something like

    StringUtils.equals(viewHolder.nameView.getText().toString(), assetName);


I found the solution in this wiki page.

His code onView(withId(;

Where withHolderTimeView is a matcher which matches a Viewholder to the item you are looking for.

Answered By – se22as

Leave a Comment