Hi I am working with APPIUM in Android. What I need to do is scroll the list page wise. I tried doing following.
MobileElement element =(MobileElement)driver.findElement(By.className("android.widget.ListView"));
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scrollTo", scrollObject);
This works but the list get scrolled continuously till the last element is displayed. What I need to do is scroll the list page wise.
This worked for me.
List<WebElement> list = driver.findElements(By.xpath("//android.widget.TextView[@resource-id='com.imdb.mobile:id/label']"));
if (list != null && !list.isEmpty()) {
WebElement bottomElement = list.get(list.size() - 1);
WebElement topElement = list.get(0);
TouchAction touchAction = newTouchAction(driver).press(bottomElement).moveTo(topElement).release();
touchAction.perform();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With