TouchAction已弃用。任何指针的新用法做垂直滚动?下面的代码使用。但不建议使用TouchAction。
Dimension dimension =driver.manage().window().getSize();
int start_x=(int) (dimension.width*0.5);
int start_y=(int) (dimension.height*0.9);
int end_x=(int) (dimension.width*0.2);
int end_y=(int) (dimension.height*0.1);
TouchAction touch =new TouchAction(driver);
touch.press(PointOption.point(start_x,start_y))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))
.moveTo(PointOption.point(end_x, end_y))
.release()
.perform();
Thread.sleep(3000);
dimension =driver.manage().window().getSize();
start_x=(int) (dimension.width*0.2);
start_y=(int) (dimension.height*0.2);
end_x=(int) (dimension.width*0.5);
end_y=(int) (dimension.height*0.8);
touch =new TouchAction(driver);
touch.press(PointOption.point(start_x,start_y))
.waitAction(WaitOptions.waitOptions(Duration.ofSeconds(1)))
.moveTo(PointOption.point(end_x, end_y))
.release()
.perform();
3条答案
按热度按时间kxe2p93d1#
在Selenium 4/Appium 8中,
TouchActions
被替换为W3C操作。http://appium.io/docs/en/commands/interactions/actions/
例如:
mbjcgjjk2#
对于隐含的问题,这是一个很好的解决方案,但是你如何在这里利用一个特定的元素呢?因为在这种情况下看起来像是在屏幕上的某个点上执行点击,我试图将其应用到移动的屏幕上的一个小部件元素上
nimxete23#