无法在appium iOS测试上滑动

时间:2015-03-11 10:15:22

标签: java ios testng appium

在文档中,appium为java提供了以下选项:

JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, Double> swipeObject = new HashMap<String, Double>();
swipeObject.put("startX", 0.01);
swipeObject.put("startY", 0.5);
swipeObject.put("endX", 0.95);
swipeObject.put("endY", 0.5);
swipeObject.put("duration", 1.8);
js.executeScript("mobile: swipe", swipeObject);

我在测试中对此进行了集成,但在导航到可以使用滑动的屏幕后,使用滑动的方法无法执行操作...在失败例外面板中,我收到以下错误:&# 34; org.openqa.selenium.WebDriverException:尚未实现&#34;。

我想从左向右滑动,但还没有找到另一种解决方案......

更新: 我已设法使用以下代码进行滑动:

HashMap scrollObject = new HashMap();{{
    scrollObject.put("direction", "left");
}};
((RemoteWebDriver) driver).executeScript("mobile: scroll", scrollObject);

问题是,它只会滑动一次,即使多次使用......有关如何解决此问题的任何想法?

2 个答案:

答案 0 :(得分:1)

如何使用IOSDriver(驱动程序)并调用以下内容:

    driver.swipe(100, 100, 500, 500, 500);

答案 1 :(得分:0)

please refer detailed RCA of this issue with solution

问题是对于iOS appium java客户端有不同的刷卡功能!

对于Android,它的参数名称为endx和endy,它们是终点坐标!

但对于iOS,如果命名正确,则为deltaX和deltaY。

简而言之,

Positive endx = Right direction and magnitude of endx defines swipe size
Negative endx = Left direction and magnitude of endx defines swipe size
Positive endy = Down direction and magnitude of endy defines swipe size
Negative endy = UP direction and magnitude of endy defines swipe size

StartX和StartY是笔划起点的坐标!

让我们举个例子

1. swipe(100,200,10,20,300) => swipe starting from Point (100,200) and end at Point (110,220) which means finger would move Right lower side fro current position
2. swipe(100,200,-10,20,300) => swipe starting from Point (100,200) and end at Point (90,220) which means finger would move Left lower side from current position
3. swipe(100,200,10,-20,300)=> swipe starting from Point (100,200) and end at Point (110,180) which means finger would move Right Upper side from current position
4. swipe(100,200,-10,-20,300)=> swipe starting from Point (100,200) and end at Point (90,180) which means finger would move Left Upper side from current position