1

I'm trying to test a RecyclerView using Espresso's framework and currently hitting into the following issue -

Espresso's method

    fun scrollToItemAndCheck() {
         onView(withId(R.id.recycler_view))
              .perform(scrollTo<RecyclerView.ViewHolder(hasDescendant(withText("item text"))))
}

RecyclerView -

<android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical" />

Issue - scrollToItemAndCheck() throws an AppNotIdleException.

Note - The same method starts working fine when I wrap the RecyclerView inside a FrameLayout

<FrameLayout>
    android:layout_width="match_parent"
    android:layout_height="match_parent"
   <android.support.v7.widget.RecyclerView
            android:id="@+id/recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
</FrameLayout>

Any clue as to what's going on?

Aggarwal
  • 11
  • 3
  • When are you calling `scrollToItemAndCheck()`? The RecyclerView may be binding views, have you tried calling it after the recyclerview has fully loaded? – ayvazj Jun 22 '18 at 18:40
  • Yes! Calling it after the recyclerView has fully loaded! – Aggarwal Jun 23 '18 at 23:06

0 Answers0