【问题标题】:Cannot swipe on appium iOS test无法在appium iOS测试上滑动
【发布时间】:2015-05-13 01:51:35
【问题描述】:

在文档中,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);

我在我的测试中集成了这个,但是在导航到可以滑动的屏幕后,带有滑动的方法将不会执行该操作...在失败异常面板中,我收到以下错误:“org.openqa .selenium.WebDriverException:尚未实现”。

我想从左向右滑动,但还没找到其他解决方案...

更新: 我已经设法使用以下代码刷卡:

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

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

【问题讨论】:

    标签: java ios testng appium


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      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
      

      【讨论】:

        猜你喜欢
        • 2016-10-20
        • 2020-08-06
        • 2015-05-27
        • 2019-01-21
        • 2014-02-11
        • 2015-11-22
        • 2017-03-23
        • 2018-11-26
        • 2015-05-10
        相关资源
        最近更新 更多