Scroll to an element in android chrome browser

Hi All,

I have created a web application for mobile. i want to test it using appium. i am using python client of appium. In this i want appium to click on a link which may not be on the current screen. We may have to scroll down and click. The position of the link is dynamic and depends on the other content. So i want to scroll until that element is visible on the screen and click on the link. For achieving this i tried following
driver.execute_script(“mobile: scrollTo”, {“element”: element_to_click.id}). but that didnt work. Can somebody help me in achieve this.

Thanks in advance

Hi @skalluraya

in java we’ll use driver.scrollToExact(“name of the locator”), it will scroll up and down the entire page until element found

Review this thread to see if it contains any helpful information:

Hi !
look this !
public void scrollElementoWeb(def params){

    MobileElement element = Elementos.find(params, Driver.driver);
    JavascriptExecutor js = (JavascriptExecutor) Driver.driver;
    try{
        int x = element.getLocation().getX();
        int y = element.getLocation().getY();
        js.executeScript("window.scrollBy(" + x + "," + y + ")", "");
    }catch(Exception e){
        try{
            js.executeScript("arguments[0].scrollIntoView(true);",element);
        }catch(Exception f){
            assert false,"No se pudo realizar scroll en la pagina web en el elemento ${params."Tipo ID"}:'${params.ID}'. ${f}"
        }
    }   
}`

try running this script ! this is groovy but the js functions is the key! :wink: