Skip to content Skip to sidebar Skip to footer

Espresso Recyclerview Inside Viewpager

I am new to Android Espresso library. Trying to test click on RecyclerView item inside the ViewPager. I've searched the Internet but found nothing about ViewPager. So my question i

Solution 1:

Let's suppose you want to tap on buttonClick, which is the id of a button inside your RecyclerView.

I use this code:

onView(allOf(withId(R.id.buttonToClick), isCompletelyDisplayed()))
            .perform(click());

This gets the view with this id which is currently displayed and performs a click on it.

Hope this helps.

P.S.: Also, on espresso-contrib there are RecyclerViewActions that maybe you can use: actionOnHolderItem, actionOnItem and actionOnItemAtPosition. You can do something like:

onView(withId(R.id.recyclerView))
    .perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));

Post a Comment for "Espresso Recyclerview Inside Viewpager"