如何在Appium Java iOS中向上,向下,向左和向右滑动

时间:2018-12-28 07:45:54

标签: java ios maven appium

.moveTo()显示此错误:

  

未为类型WaitOptions定义方法moveTo(PointOption)。

我执行提供的快速修复,将强制类型转换添加到方法接收器,然后发生以下错误:

  

TouchAction类型的方法waitAction(WaitOptions)不适用于参数(TouchAction)

  • java版本1.8.0_191
  • 模拟器-iPhone x(iOS 12)
  • Appium版本1.9.0

    公共静态无效刷卡(MobileDriver驱动程序,方向,持续时间长){     org.openqa.selenium.Dimension size = driver.manage()。window()。getSize();

    int startX = 0;
    int endX = 0;
    int startY = 0;
    int endY = 0;
    
    switch (direction) {
        case RIGHT:
            startY = (int) (size.height / 2);
            startX = (int) (size.width * 0.90);
            endX = (int) (size.width * 0.05);
            TouchAction action = new TouchAction(driver);
            action.press(PointOption.point(427, 878))
            .waitAction(WaitOptions
                    .waitOptions(Duration
                            .ofMillis(1300))
                    .moveTo(PointOption.point(427, 554))
                    .release().perform();
    
            break;
    
        case LEFT:
            startY = (int) (size.height / 2);
            startX = (int) (size.width * 0.05);
            endX = (int) (size.width * 0.90);
            new TouchAction(driver)
                    .press(startX, startY)
                    .waitAction(Duration.ofMillis(duration))
                    .moveTo(endX, startY)
                    .release()
                    .perform();
    
            break;
    
        case UP:
            endY = (int) (size.height * 0.70);
            startY = (int) (size.height * 0.30);
            startX = (size.width / 2);
            new TouchAction(driver)
                    .press(startX, startY)
                    .waitAction(Duration.ofMillis(duration))
                    .moveTo(endX, startY)
                    .release()
                    .perform();
            break;
    
    
        case DOWN:
            startY = (int) (size.height * 0.70);
            endY = (int) (size.height * 0.30);
            startX = (size.width / 2);
            new TouchAction(driver)
                    .press(startX, startY)
                    .waitAction(Duration.ofMillis(duration))
                    .moveTo(startX, endY)
                    .release()
                    .perform();
    
            break;
    
    }
    

    }

如果使用public enum DIRECTION { LEFT },我希望它向左滑动。

0 个答案:

没有答案