我试图向下滑动联系人屏幕,但它无法正常工作.
这是我试过的代码.
public void Swipedown() throws InterruptedException
{
// Select till which position you want to move the seekbar
TouchAction action=new TouchAction((PerformsTouchActions) driver);
Dimension dimensions = driver.manage().window().getSize();
action.press(446,1404).moveto(554,1500).release().perform();
System.out.println("swipe down to set seekbar successfully");
Thread.sleep(5000);
}
你能帮我解决一下我在做错的事吗?
任何帮助将受到高度赞赏.
解决方法:
使用以下方法向下/向上滑动:
public static void swipeVertical(AppiumDriver driver, double startPercentage, double finalPercentage, double anchorPercentage, int duration) throws Exception {
Dimension size = driver.manage().window().getSize();
int anchor = (int) (size.width * anchorPercentage);
int startPoint = (int) (size.height * startPercentage);
int endPoint = (int) (size.height * finalPercentage);
new TouchAction(driver).press(anchor, startPoint).waitaction(Duration.ofMillis(duration)).moveto(anchor, endPoint).release().perform();
}
向上滚动:swipeVertical((AppiumDriver)驱动程序,0.9,0.1,0.5,3000);
向下滚动:swipeVertical((AppiumDriver)驱动程序,0.1,0.9,0.5,3000);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。