我正在尝试使用下面的方法在 native android 应用程序中滚动
Dimension size = driver.manage().window().getSize();
int starty = (int) (size.height * 0.80);
int endy = (int) (size.height * 0.20);
int startx = size.width / 2;
driver.swipe(startx, starty, startx, endy, 3000);
Thread.sleep(2000);
但是在 driver.swipe
它给了我一个错误
The method swipe(int, int, int, int, int) is undefined for the type AndroidDriver
谁能帮我解决这个问题?我一直在寻找解决方案,但一直没有成功。
最佳答案
您可以使用 TouchAction
代替 .swipe
:
TouchAction action = new TouchAction(driver);
action.press(x, y).moveTo(x, y).release().perform();
您还可以使用 PointOption
实现 x y
,如下所示:
.press(new PointOption().withCoordinates(x, y))
或者
.press(PointOption.point(x, y))
导入后:
import io.appium.java_client.TouchAction;
关于java - 如何使用 appium 坐标滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58090767/