Issue
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.
Solution
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())
Answered By - azizbekian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.