scrollToExact() or scrollTo() Usage!

Hi All.

I need to scrollTo a particular Country in a “Country List”.

Looking at the above Image,I need to Scroll the Screen to find the Country “Belgium”.

    driver.scrollTo("Belgium");
    driver.findElement(By.xpath("//android.widget.TextView[@text='Belgium']")).click();

Result of the above snippet : The scrolling is continues even the ‘Belgium’ is passed and more over it doesn’t click on the “Belgium”.

Is this a problem because of it is in TextView or Liner Layout?

Need help on this!!

Write your custom scrolls using

driver.swipe method or TouchActions class

(driver.scrollTo and driver.scrollToExact) these are unreliable methods.

I filed an issue over a year ago with the ruby library for scroll_to and scroll_to_exact. There was a problem with these two methods because they look for both text and description, and some logic was broken. We liberated the code and only search for one of the two. This has worked reliably for us. I suspect you can do something similar with the Java code.