Appium - 滚动方法在IOS的横向模式下不起作用

时间:2018-03-14 16:10:02

标签: javascript selenium appium appium-ios appium-desktop

下面提到的滚动方法在纵向模式下工作正常,但在横向模式下,滚动方法对IOS不起作用。

Appium版本:1.7.1

IOS版本:11.2

模拟器/真实设备:模拟器 - IPhone SE

请帮助!!

@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);
}

1 个答案:

答案 0 :(得分:1)

我遇到了同样的问题。在我的情况下,问题是应用程序从纵向模式获取坐标,即使它处于横向模式。所以请检查纵向模式和坐标模式下的坐标。景观模式是否相同。