Scrolling the page till the end

How to scroll a page till the end using java

// use below code to scroll down the page. Below code works fine for me in iOS app.

public static void scrollDown(AppiumDriver driver, WebElement element) {
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObjects = new HashMap<String, String>();
scrollObjects.put(“direction”, “down”);
scrollObjects.put(“element”, ((RemoteWebElement) element).getId());
js.executeScript(“mobile: scroll”, scrollObjects);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

Thank you!! It worked for me.

1 Like