scrollIntoView Inconsistent Behaviour


I have used a snippet of code to have a vertical scrollIntoView function
hook.driver).findElementByAndroidUIAutomator(“new UiScrollable(new

In the Search Screen, this function works fine where it keeps scrolling downwards till the element is found. However, in another screen, the scroll is very minimal where it scrolls few pixels downwards then a few pixels upwards on loop till it times out.

Is there a reason why such function behaves different in each screen? And how to fix this issue?

If there’s no issue in the code, I have seen many scrolling functions and each is a personal preference in implementation. Is there any best practice helper function that scrolls in this recycler view till an element is found?

Thank you

UiScrollable - is pure UiAutomator command which Android system controls itself.

All you can do is tune the command in cases when we have e.g. many scroll views on screen or they have different layout (horizontal / vertical). Try specify more exactly in command which scrollView to use (e.g. you can specify it resource-id) and layout.

Hi @Aleksei ,

Thank you for your response. Can you please supply an example of what you meant by being more specific? I tried and the UiSelector constructor did not work well.

Thank you

Here they are

1 Like

BTW if all fails you always can switch to swipe by coordinates. see examples in doc.

Hi @Aleksei,
Thank you for the documentation link it was helpful. However, no matter what I did the scroll behaviour would not change. Then I found a temporary solution for now and it is working fine.
The solution I implemented was to call flingForward() function then I will call the scrollIntoView(). This fixed the issue, however, the screen goes to the middle of the list then searches for the element from the start. It is not the best solution out there but it got it to work.

Thank you!

all such oddness on Android side. glad you make workaround.

1 Like