我想进行水平滑动,是否可以使用appium webdriverio在Android手机上完成任何操作。
答案 0 :(得分:0)
您可以使用 io.appium.java_client.TouchAction
创建自定义滑动方式public void horizontalSwipeByPercentage(double startPercentage, double endPercentage,
double anchorPercentage, AppiumDriver<MobileElement> driver) {
Dimension size = driver.manage().window().getSize();
int anchor = (int) (size.height * anchorPercentage);
int startPoint = (int) (size.width * startPercentage);
int endPoint = (int) (size.width * endPercentage);
new TouchAction(driver)
.press(PointOption.point(startPoint, anchor))
.waitAction(WaitOptions.waitOptions(ofSeconds(1)))
.moveTo(PointOption.point(endPoint, anchor))
.release().perform();
}
对于水平滑动,锚点是固定的y坐标位置