gpt4 book ai didi

java - 无法使用 TouchActions 滚动

转载 作者:行者123 更新时间:2023-12-02 05:41:40 28 4
gpt4 key购买 nike

我能够使用我通过触摸操作编写的滚动方法,但现在运行它时出现编译错误。我现在应该使用什么或者我可以做什么来解决编译问题?

public void scrollDown() {

AndroidDriver androidDriver = ((AndroidDriver)((WebDriverFacade) getDriver()).getProxiedDriver());
TouchAction touchAction = new TouchAction(androidDriver);

Dimension size = androidDriver.manage().window().getSize();
int startX = size.width / 2;
int startY = (int) (size.height * 0.60);
int endY = (int) (size.height * 0.30);
touchAction.longPress(startX, startY).moveTo(startX, endY).release().perform(); // error on this line pointing to startX and startY within longpress()
}

下面是编译错误

method io.appium.java_client.TouchAction.longPress(io.appium.java_client.touch.offset.PointOption) is not applicable
(actual and formal argument lists differ in length)

最佳答案

您可以使用以下方法来滑动屏幕

public void verticalSwipeByPercentages(double startPercentage, double endPercentage, double anchorPercentage, AppiumDriver<MobileElement> driver) {
Dimension size = driver.manage().window().getSize();
int anchor = (int) (size.width * anchorPercentage);
int startPoint = (int) (size.height * startPercentage);
int endPoint = (int) (size.height * endPercentage);

new TouchAction(driver)
.press(PointOption.point(anchor, startPoint))
.waitAction(WaitOptions.waitOptions(ofSeconds(1)))
.moveTo(PointOption.point(anchor, endPoint))
.release().perform();
}

关于java - 无法使用 TouchActions 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56133873/

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