Issue with scrollTo and scrollToExact methods of Android Driver. Methods do not scroll to required element text, but scroll to end of page

Hi @Vallabhaneni_Rakesh,

Above methods did not work for me, so I am using a workaround using below method,
window.scrollBy(0,200).

The operation I wanted was a click, after scrolling to necessary text. There is an attribute on the element that can be checked if click has happened, so I am making use of that in a loop to achieve.

Please check this solution also, if it works. Yet to try this solution.

Code:

js = (JavascriptExecutor) driver;
js.executeScript(“window.scrollTo(0,0)”);
do
{
try
{
driver.findElement(By.xpath().click();
break;
}
catch(Exception e)
{
js = (JavascriptExecutor) driver;
js.executeScript(“window.scrollBy(0, 200)”);

}
} while(true);

Thanks,
Sujata