I want to scroll on android using javascript

Hi there,

there seems to be a big problem with scrolling in android or on any device, at the moment i’m using driver.touchPerform and sometimes it scrolls properly and sometimes it doesnt scroll at all or even scroll all the way to the bottom.

Current code
{ action: ‘press’, options: { x: 1058, y: 1700 }},
{ action: ‘wait’, options: { ms: 100 }},
{ action: ‘moveTo’, options: { x: 1058, y: 1500 }},
{ action: ‘release’ }

Is there a better way for scrolling on android or something that actually works? appreciate all your help and advice

try this tutorial(JS): https://www.youtube.com/watch?v=oAJ7jwMNFVU
it is the actions api, it should work with any platform.

if you don’t want to use hardcoded coordinates then get the coordinates from the window instance(check how to do it in js, use your driver) you should get the width and hight of the screen. I added 50 units to the starting y coordinate and decreased by 50 units the end y coordinate to make sure the scroll won’t touch the edges of the screen.

as well, you can pass a locator strategy to your scrolling method and each “scrolling iteration” check if you can find the element on the screen and validate that it is indeed displayed.


could you show me an example?
actually write the code with an example please? i am a newbi in coding


look at these examples. Unfortunately I don’t work with JS so I don’t want to cause mistakes in your code. There are other tutorials on Appium home page(where the links lead to).