How to Click on an Item Inside a Recyclerview in Espresso

Using Espresso to click view inside RecyclerView item

You can do it with customize view action.

public class MyViewAction {

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();
}
};
}

}

Then you can click it with

onView(withId(R.id.rv_conference_list)).perform(
RecyclerViewActions.actionOnItemAtPosition(0, MyViewAction.clickChildViewWithId(R.id. bt_deliver)));

How to click on a button within a recycler view item using espresso?

Have a look at the following stackoverflow question:
It creates a ViewAction that clicks a view object, identified by id, at a specific position in the recyclerView.

Using Espresso to click view inside RecyclerView item



Related Topics



Leave a reply



Submit