【问题标题】:How can I do horizontal swipe until desired element is found in webdriverio for mobile automation?如何进行水平滑动直到在 webdriverio 中找到用于移动自动化的所需元素?
【发布时间】:2019-06-11 12:45:32
【问题描述】:

我想做水平滑动,有什么方法可以使用 appium webdriverio 为 android 的移动设备完成。

【问题讨论】:

    标签: android appium webdriver-io


    【解决方案1】:

    您可以使用 io.appium.java_client.TouchAction

    创建自定义滑动方法
    public void horizontalSwipeByPercentage(double startPercentage, double endPercentage,
                      double anchorPercentage, AppiumDriver<MobileElement> driver) {
      Dimension size = driver.manage().window().getSize();
      int anchor = (int) (size.height * anchorPercentage);
      int startPoint = (int) (size.width * startPercentage);
      int endPoint = (int) (size.width * endPercentage);
    
      new TouchAction(driver)
            .press(PointOption.point(startPoint, anchor))
            .waitAction(WaitOptions.waitOptions(ofSeconds(1)))
            .moveTo(PointOption.point(endPoint, anchor))
            .release().perform();
    }
    

    对于水平滑动,锚点是固定的y坐标位置

    【讨论】:

      猜你喜欢
      • 2018-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-24
      相关资源
      最近更新 更多