Issue With Scrollto And Scrolltoexact Methods Of Android Driver. Methods Do Not Scroll To Required Element Text, But Scroll To End Of Page
We are working on a Cordova mobile application. On a screen we have a list of values in a table format. We need to perform a scroll action if we want to select an element not in vi
Solution 1:
Thank you ShlomiTC for the help, I could get it working by first checking if element is available on screen and use an infinite loop to repeat scrolling the screen till the element has been clicked. If element is not clicked, an exception occurs so a try/catch block helped me here. Hope this helps any one having similar issue.
js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0,0)");
do
{
try
{
driver.findElement(By.xpath(<xpathexpresssion>).click();
break;
}
catch(Exception e)
{
js = (JavascriptExecutor) driver;
js.executeScript("window.scrollBy(0, 200)");
}
} while(true);
Post a Comment for "Issue With Scrollto And Scrolltoexact Methods Of Android Driver. Methods Do Not Scroll To Required Element Text, But Scroll To End Of Page"