Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Espresso: how to scroll to the bottom of ScrollView

How is it possible to scroll down to the bottom of ScrollView in Espresso test? Thanks!

like image 902
Kid24 Avatar asked May 22 '15 02:05

Kid24


People also ask

How do you scroll scroll view in espresso?

If at the bottom of the ScrollView you need to find a view and match something against it, then simply perform the scrollTo() action on it, before any other actions that require it to be displayed. works only if you know your child elements - what to do if you dont know the last element?

How do you swipe espresso?

As you may know the latest Espresso release contains new left and right swiping actions: swipeLeft() and swipeRight() . They both are really useful when you'd like to swipe between activity fragments, tab layouts or any other UI elements. You can use it as any other view action: onView(withId(R.


1 Answers

If at the bottom of the ScrollView you need to find a view and match something against it, then simply perform the scrollTo() action on it, before any other actions that require it to be displayed.

onView(withId(R.id.onBottomOfScrollView))     .perform(scrollTo(), click()); 

Note: scrollTo will have no effect if the view is already displayed so you can safely use it in cases when the view is displayed

like image 88
appoll Avatar answered Sep 23 '22 23:09

appoll