I am trying to swipe a horizontal scrollview using swipe gesture but its not working. I only have one scroll view on the current screen.
WebElement ticketList=driver2.findElement(By.className(“android.widget.HorizontalScrollView”));
((JavascriptExecutor)driver2).executeScript("mobile:swipeGesture", ImmutableMap.of("elementId",((RemoteWebElement)ticketList).getId(),
"direction","left",
"percent",1));
WebElement ticketList=driver2.findElement(By.className(“android.widget.HorizontalScrollView”));
boolean canScrollMore;
do {
canScrollMore=(Boolean)((JavascriptExecutor)driver2).executeScript("mobile:scrollGesture", ImmutableMap.of("elementId",((RemoteWebElement)ticketList).getId(),
"direction","right",
"percent",1));
}while(canScrollMore);
This did the trick
you are basically calling this function repeatedly until it returns a truthy value? How is that a “fix” or a trick?
I wanted to scroll till end of this scroll view. This does that.
It’s just rather curious looking code, together with how the “percent” parameter in the driver does not do what the reader might think, made it hard to understand that we are scrolling 100% of the length of the control not 1%.