gpt4 book ai didi

java - 如何在appium Java IOS中上下左右滑动

转载 作者:行者123 更新时间:2023-11-29 11:30:38 24 4
gpt4 key购买 nike

.moveTo()//显示此错误:未定义类型 WaitOptions 的方法 moveTo(PointOption)。

我执行提供的快速修复,即:将强制转换添加到方法接收器

以下错误显示:TouchAction 类型中的方法 waitAction(WaitOptions) 不适用于参数 (TouchAction)

Java 版本“1.8.0_191”模拟器 - iPhone x (IOS 12)应用程序 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;

}
}

如果使用

公共(public)枚举方向{左}

我希望它向左滑动

最佳答案

waitAction 方法不接受 java.time.Duration 持续时间 它必须使用 waitOptions 传递,就像您在 中使用的那样正确的 案例。检查 waitOptions 详细信息 here

同样moveTopress接受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();

关于java - 如何在appium Java IOS中上下左右滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53955245/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com