Search code examples
androidandroid-espressorobotium

Robotium scroll to view


I can do this in Android Espresso:

onView(withId(R.id.footer)).perform(scrollTo());

While doing this, the test framework will scroll the screen onto the view (the view is on a scroll view).

But I couldn't find this basic function in Robotium, I personally lot prefer Robotium over Espresso, but quite surprise they kind of do not have this function? Do I miss anything?


Solution

  • Ok, I just found a simple way, instead of relying on Robotium drag() method, in the instrumentation test case, I can directly getView the scrollview and perform its original android function scrollview.scrollTo(x,y), which is quite good enough to achieve my objective.

    Example:

    ScrollView verticalSv = (ScrollView) solo.getView(R.id.verticalScrollView);
    verticalSv.scrollTo(0, 100);