[英]How to swipe Up, Down, Left and right in appium Java IOS
.moveTo() // 显示此错误:方法 moveTo(PointOption) 未定义为 WaitOptions 类型。
我做了提供的快速修复,即:将强制转换添加到方法接收器
以下错误显示:TouchAction 类型中的方法 waitAction(WaitOptions) 不适用于参数 (TouchAction)
java 版本“1.8.0_191”模拟器 - iPhone x (IOS 12) Appium 1.9.0
public static void swipe(MobileDriver driver, DIRECTION direction, long duration) {
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;
}
}
如果使用
公共枚举方向{左}
我希望它向左滑动
waitAction
方法不接受java.time.Duration duration
它必须使用waitOptions
传递,就像您在RIGHT
情况下使用的那样。 在此处检查waitOptions
详细信息
同样moveTo
和press
接受PointOptions
和直接坐标不能传递。
case LEFT:
startY = (int) (size.height / 2);
startX = (int) (size.width * 0.05);
endX = (int) (size.width * 0.90);
new TouchAction(driver)
.press(PointOption.point(startX, startY))
.waitAction(WaitOptions
.waitOptions(Duration
.ofMillis(duration))
.moveTo(PointOption.point(endX, startY))
.release()
.perform();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.