Search code examples
javascriptseleniumappiumappium-iosappium-desktop

Appium - Scrolling methods are not working in landscape mode for IOS


Below mentioned scrolling methods are working fine in portrait mode but, in landscape mode scrolling methods are not working for IOS.

Appium Version: 1.7.1

IOS Version: 11.2

Simulator / Real Device: Simulator - IPhone SE

Please help!!

@Test
public  void ScrollWithElementByName(RemoteWebDriver driver, String XPath) throws InterruptedException
{
    RemoteWebElement elements =  (RemoteWebElement) driver.findElement(By.name(XPath));
    JavascriptExecutor js = (JavascriptExecutor) driver;
    HashMap<String, String> scrollObject = new HashMap<String, String>();
    scrollObject.put("element", ((RemoteWebElement) elements).getId());
    scrollObject.put("toVisible", "true");
    js.executeScript("mobile: scroll", scrollObject);
}

@Test
public void ScrollWithoutElement(RemoteWebDriver driver) throws InterruptedException
{
    Dimension size = driver.manage().window().getSize();       
    JavascriptExecutor js = (JavascriptExecutor) driver;
    HashMap<String, String> scrollObject = new HashMap<String, String>();
    scrollObject.put("direction", "down");
    js.executeScript("mobile: scroll", scrollObject);
    scrollObject.put("direction", "up");
    js.executeScript("mobile: scroll", scrollObject);
}

Solution

  • I have faced same issue.In my case,the problem was the application was taking the coordinates from portrait mode even though it was in landscape mode.So please check coordinates in both portrait mode & landscape mode whether they are same or not.