How to Swipe in app

Currently I use these code to perform swipe down in app but nothing happens. Please help

public void swipingVertical() throws InterruptedException {
    size = driver.manage().window().getSize();

    int starty = (int) (size.height * 0.8);
    int endy = (int) (size.height * 0.2);
    int startx = size.width / 2;

    //Swipe from Bottom to Top.
    new TouchAction(driver).press(PointOption.point(startx, starty)).
            moveTo(PointOption.point(startx, endy)).release().perform();

try the below code.
int width = dim.getWidth() / 2;
int startY = (int) (dim.getHeight() * 0.3);
int endY = (int) (dim.getHeight() * 0.7);
new TouchAction(driver).press(point(width, startY)).waitAction(waitOptions(Duration.ofSeconds(1)))
.moveTo(point(width, endY)).release().perform();

I’ve already use waitAction but if I input it to the code I will get this error:

org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: The swipe did not complete successfully
Build info: version: ‘3.14.0’, revision: ‘aacccce0’, time: ‘2018-08-02T20:05:20.749Z’

user the same code i wrote and let me know the result please

The result same as my current result, nothing happens after run your code, screen is not scrolled

Hi @Bilal_Jarwan tks for your help but currently after reinstall app, Im running my old code it’s working now, tks anw :smiley:

sounds good :slight_smile:

1 Like