1

下面提到的滚动方法在纵向模式下工作正常,但在横向模式下滚动方法不适用于 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);
}
4

1 回答 1

1

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

于 2018-04-05T06:32:34.577 回答