vendredi 2 mars 2018

Testing a RecyclerView: RecyclerViewActions isn't scrolling far enough

I want my espresso test to scroll a RecyclerView down until it's sees a certain view and clicks it.

Therefore I am using RecyclerViewActions:

onView(withId(R.id.recycler)).perform(
          RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
                  hasDescendant(withText(R.string.title_item_x))
          )
)
Thread.sleep(2000)
onView(withId(R.id.recycler)).perform(
          RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
                  hasDescendant(withText(R.string.title_item_x)),
                  click()
          )
)

The test scrolls the RecyclerView down, but only about 50% of the needed amount. The click call crashes because of it.

Does somebody encountered something similar?

Thanks!

Aucun commentaire:

Enregistrer un commentaire