gpt4 book ai didi

java - 如何使用 Appium 在 iOS 中滑动

转载 作者:行者123 更新时间:2023-12-01 21:59:04 26 4
gpt4 key购买 nike

我正在尝试使用 Appium 和 java 在 iOS 中向下滑动模态视图。

我试过这两种方法都没有成功:

JavascriptExecutor js2 = (JavascriptExecutor) driver;

HashMap<String, String> scrollObject2 = new HashMap<String, String>();
scrollObject2.put("x", "200");
scrollObject2.put("y", "550");
scrollObject2.put("direction", "down");
js2.executeScript("mobile: swipe", scrollObject2);

TouchAction action = new TouchAction(driver);
action.press(PointOption.point(200, 550)).moveTo(PointOption.point(200, 700)).release().perform();

我做错了什么?是实现这一目标的另一种正确方法吗?

谢谢!

最佳答案

您应该使用 js 脚本执行器来执行此操作。

无需像您那样添加坐标,只需尝试以下操作:

HashMap<String, String> scrollObject = new HashMap<>();
JavascriptExecutor js = driver;
scrollObject.put("direction", "down");
js.executeScript("mobile: scroll", scrollObject); //or "mobile: swipe"

关于java - 如何使用 Appium 在 iOS 中滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60667361/

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