Appium 无法在 iOS 8.4 上滚动

Appium not able to scroll on iOS 8.4

我正在尝试使用以下代码在 Appium 上成功滚动:

// java
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "down");
scrollObject.put("element", ((RemoteWebElement) element).getId());
js.executeScript("mobile: scroll", scrollObject);

但是,由于已知的 appium 问题,在尝试滚动到 UITableView 底部之外时出现 javascript 错误: https://github.com/appium/appium/issues/4836

这个问题伴随着 appium 的 isDisplayed() 方法总是 returns true(无论单元格在屏幕上是否可见)并且 appium 无法点击不可见的单元格,这意味着 appium无法滚动和 select 个对象。

有没有人找到解决这个问题的方法?

使用轻弹作为可能的临时解决方案。我们可以在屏幕上滑动和滚动时轻拂,elements.We 实际上不能在 UIAScrollView 上轻拂,但我们可以在 UIACollectionView 上轻拂。

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap scrollObject = new HashMap();
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject);

要解决 isDisplayed() 总是 true 的问题,您可以尝试

 if(!driver.findElements(By.name(using)).isEmpty()) {
...
}

将 'using' 替换为您的定位器,而且我认为这个滚动问题必须由 Appium mobile:scroll 解决,并且您的代码看起来不错,您也可以尝试使用 Vertical swipe 而不是 Scroll .

所以目前看来可能没有办法解决这个问题。 Darshan 上面提到这个滚动问题在 iOS 8.4 中仍然存在,并且从网上冲浪似乎其他人也有相同的看法