We’re using appium to automate an android app, using only UIAutomator strings, such as the following:
new UiScrollable(new UiSelector().resourceId("xyz").scrollable(true)).scrollIntoView(new UiSelector().resourceId("abc"))
Now there’s a problem where Appium/UIAutomator stops scrolling into one direction and starts scrolling into the opposite direction - even though the end of the scrollview has not been reached yet. To find hints towards why this is happening we need to know the algorithm that’s used by the scrolling function of appium/uiautomator.
How does the scrolling algorithm decide whether or not to change the scrolling direction?
before starting to scroll opposite did few attempts where made to scroll in correct direction?
where this few attempts really scroll happen?
my guess that it just tries to scroll and if scroll not happen -> then algorithm realize that scroll ends.
BTW in my observe first it tries to reach start scroll for sure then goes to end. Example: we have country list - Angola, England, USA. With default England selected. Then first it scroll into begining to Angola and then starting to look for needed value.
Yes it starts scrolling into the correct direction but before reaching the end of the scrollview, it will scroll into the opposing direction. It will actually scroll up and down in the same bounds after that for a few times.
The question is, how does appium/UIAutomator recognize if a scrollview end has been reached or not. My current guess is, it will take elements inside the scrollview and compare the location of those elements before and after scrolling. If the location is the same after scrolling, it changes scroll directions.
We are using many very generic elements inside the app, for this reason I think the UIAuotmator might confuse another element for the one it scanned before scrolling and misjudges the descision to start scrolling into the opposite direction.
i.e. My guess is, the scroll algorithm has no certain way to tell if a scrollview end has been reached, instead it will guess based on child elements if the end has been reached or not
I am noticing exactly the same problem with the UIAutomator scrolling. I was thinking UIautomator gets confused due to the way my test app is constructed, but I guess I am not the only one with this issue.
My automation also goes up and down a few times in the beginning and it scrolls to the correct direction.
This is unrelated to Appium, but I would also like to to know what’s going on.
How to scroll if there is no text and resourceId present in element like in gallery section there is no text and content-desc and resourceId only classes are present for image