Vertical scrolling issue


I am trying to do vertical scrolling on homepage using the below code

My requirement is like this I need to find one element having text videos on the homepage which is on the bottom of the page.

driver.findElementByAndroidUIAutomator(“new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains(“Videos”).instance(0))”);

Sometimes this scrolling is working and sometimes it’s not. Can anyone please let me know why this is sometimes working and sometimes not.


1 Like

Are your screens in some kind of transition? You may want to ensure that the screen is loaded before you start scrolling. In my code I will find a particular element that identifies the screen, and surround that find with an implicit wait. Once the screen has loaded you can start scrolling. Otherwise if the scrolling begins before the elements of the screen have loaded you will have varying results like what you are seeing.