I have a Fragment
that contains RecyclerView
. But since I have a lot of elements in this Fragment
, I want to swipe up the list to see and check all the elements that are in this Fragment
.
Earlier this method helped me, but now for some reason it does not work:
Espresso.onView(ViewMatchers.withId(R.id.recyclerView)).perform(ViewActions.swipeUp())
I have many RecyclerView
s with same id
in my project:
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
Also in my tests I've written something like this:
onView(allOf( withId(R.id.recyclerView), isDisplayed()))
onView(withId(R.id.recyclerView)).perform(swipeUp())
But caught error only on second line.
android.support.test.espresso.AmbiguousViewMatcherException: 'with id: com.fentury.android:id/recyclerView' matches multiple views in the hierarchy. Problem views are marked with '****MATCHES****' below.
You have multiple views with id R.id.recyclerView
in your view hierarchy, therefore espresso lacks to perform correct matching. Make the id
s of those RecyclerView
s unique.
onView(allOf(withId(R.id.recyclerView), isDisplayed()))
onView(withId(R.id.recyclerView)).perform(swipeUp())
But caught error only on second line.
Then perform matching this way:
onView(allOf(withId(R.id.recyclerView), isDisplayed())).perform(swipeUp())
Solution:
onView(allOf(withId(R.id.recyclerview), isDisplayed())).perform(swipeUp());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With