【问题标题】:How to scroll in iOS app using Selenium-Appium v1.7.2如何使用 Selenium-Appium v​​1.7.2 在 iOS 应用中滚动
【发布时间】:2018-09-07 13:18:07
【问题描述】:

我使用了以下方法,但在Swipe() 方法上显示错误。此方法在驱动程序类中不可用。所以,请建议我们是否可以通过其他方式滚动iOS Appium v1.7.2

Dimension size = driver.manage().window().getSize();
int x = size.getWidth() / 2;
int starty = (int) (size.getHeight() * 0.60);
int endy = (int) (size.getHeight() * 0.10);
driver.swipe(x, starty, x, endy, 2000);

【问题讨论】:

标签: appium-ios


【解决方案1】:

对于最新版本的appium,您不能使用.swipe(),因为此方法已被弃用。您必须使用TouchAction 类在最新的appium 中实现滚动功能。

请参考以下有关触控操作的链接:

Touch Actions in Appium

【讨论】:

    【解决方案2】:

    你可以使用下面的方法,

    /**
         * Swipe vertically upwards
         *
         * @author xxx
         * 
         * @param ele
         *            -reference field/area to swipe
         * 
         */
    public void verticalSwipe_Up(MobileElement ele) {
        Dimension size = ele.getSize();
        ElementOption press = element(ele, size.width / 2, (int) (size.height * .80));
        ElementOption move = element(ele, size.width / 2, 25);
        TouchAction swipe = new TouchAction(getDriver()).press(press).waitAction(waitOptions(Duration.ofMillis(1000))).moveTo(move).release();
        // ofSeconds(2)
        swipe.perform();
    }
    

    您可以相应地更改值以执行向下/向右/向左滑动

    【讨论】:

      猜你喜欢
      • 2015-05-06
      • 1970-01-01
      • 2018-11-15
      • 2017-03-23
      • 2020-06-25
      • 2019-02-07
      • 2018-02-02
      • 2018-08-08
      • 2020-04-22
      相关资源
      最近更新 更多