How to scroll to bottom of list with UIAutomator2

Using UIAutomator2, how to scroll to bottom of the list? I have very long list and I need to test each item in that list. I created ‘contentDescription’ for each item so I have “Item_XX” (where XX is position/index in list), but before I start checking items one by one, I need to know which ItemId is last…

Is my only way how to do it just do multiple scrolls until I hit end? Is there any way how to scroll just to bottom and detect, that I am on bottom?

Try Swipe Tutorial - Appium

If you only have access to application accessibility layer then it is impossible to figure out the exact scroll duration. That is why scrolls are done in a loop and on each loop iteration the algorithm should verify if the condition that stops the scrolling is satisfied. UiScollable stuff, btw, does exactly the same manipulations, just implicitly. In Espresso though, there is a way to achieve something like that using android datamatcher location strategy. See, for example, https://www.youtube.com/watch?v=gU9EEUV5n9U

Yea… But I cannot use Espresso, because I will be unable to also use UIAutomator features…

So, how can I use UIScrollable to scroll to bottom and stop? Does it check for end?

AFAIK it does not. You could try https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-mobile-gestures.md#mobile-scrollgesture
This API returns false if it is not possible to scroll more in the given direction.

1 Like

Thanks that should help

Sadly mobile: scrollGesture command doesnt do anything on Android and always return false…

did you try ‘flingToEnd’ with specifying max tries?