0
votes

enter image description here

I am automating hybrid app. I want click on sign out which is not visible on the page and hence I need to scroll down to click on it. I am trying with below code but it's not working and I am using Java client 5.0.4 Appium server 1.7.2 and selenium 3.9.1 and Java jdk version 1.8.0_161. Can any one please help

JavascriptExecutor js = (JavascriptExecutor)driver;
        HashMap<String, String> scrollObject = new HashMap<String, String>();
        scrollObject.put("direction", "down");
        js.executeScript("mobile: scroll", scrollObject); 
        do 
        {
        try{
        ele1.click();
        break;
        }
        catch(Exception e){
            js.executeScript("mobile: scroll", scrollObject); 
        }
        } while(true);
1

1 Answers

-3
votes

Check out this link. I have not used it for hybrid app but it may help you. It provides solution to scroll page vertically using Android Driver.
http://www.qaautomated.com/2016/02/how-to-scroll-in-appium.html

I have tried this code and it worked for me to click on object which is not visible on screen. You can try this.

MobileElement abc = (MobileElement) driver.findElement(MobileBy.AndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView("
                  +"new UiSelector().text(\"Country\"));"));
          abc.click();

Replace "Country" with your text or resource-id. Check this link for how to use UiSelector which helps me to find this solution. http://www.automationtestinghub.com/uiselector-android/