Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check text on position in recycler

I have method, where i click on position my recyclerView:

Espresso.onView(ViewMatchers.withId(R.id.recyclerView))
        .perform(RecyclerViewActions.actionOnItemAtPosition<CurrencySelectorItemHolder>(1, ViewActions.click()))

But how i can just check on position my text for example?

like image 491
Inkognito Avatar asked Feb 10 '17 13:02

Inkognito


1 Answers

Change "whatever" to the text you want :

Espresso.onView(withId(R.id.recyclerView))
      .perform(RecyclerViewActions.actionOnItem(
                hasDescendant(withText("whatever")), click()));

UPDATE : this code for checking text by position :

onView(withRecyclerView(R.id.recyclerView).atPosition(3))
    .check(matches(hasDescendant(withText("whatever"))));

public static RecyclerViewMatcher withRecyclerView(final int recyclerViewId) {
    return new RecyclerViewMatcher(recyclerViewId);
}

RecyclerViewMatcher.java

like image 171
Abdennacer Lachiheb Avatar answered Nov 18 '22 12:11

Abdennacer Lachiheb