Selenium webdriver 在应用程序中左右滑动
如何在最新版本的appium中实现左右移动,因为我们在新的appium版本中没有swipe(driver.swipe)方法Selenium webdriver 在应用程序中左右滑动,selenium-webdriver,appium,ui-automation,Selenium Webdriver,Appium,Ui Automation,如何在最新版本的appium中实现左右移动,因为我们在新的appium版本中没有swipe(driver.swipe)方法 public DailyPicksPage swipeDailyPicksCard() throws Exception { Dimension size = agent.getMobileDriver().manage().window().getSize(); System.out.println("Dimensions of the s
public DailyPicksPage swipeDailyPicksCard() throws Exception {
Dimension size = agent.getMobileDriver().manage().window().getSize();
System.out.println("Dimensions of the screen" + size);
int startX = (int) (size.width * 0.80);
int endX = (int) (size.width * 0.20);
int width = size.width;
int duration = 2000;
int height = size.height;
int pressHeight = (int) (height * 0.80);
new TouchAction(agent.getMobileDriver()).press(PointOption.point(startX, pressHeight)).waitAction(WaitOptions.waitOptions(Duration.ofMillis(duration))).moveTo(PointOption.point(endX, pressHeight)).release().perform();
return new DailyPicksPage(params, agent);
}
您可以使用io.appium.java\u 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();
}
public void horizontalSwipeByPercentage(双起点百分比、双终点百分比、双锚点百分比、应用驱动程序){
维度大小=driver.manage().window().getSize();
int锚定=(int)(尺寸、高度*锚定百分比);
int起始点=(int)(size.width*起始百分比);
int端点=(int)(size.width*endPercentage);
新TouchAction(驱动程序)
.按(点选项.点(起始点,锚定))
.waitAction(WaitOptions.WaitOptions(of秒(1)))
.moveTo(PointOption.point(端点,锚定))
.release().perform();
}
在上述自定义方法中锚定的目的是什么?对于水平滑动,锚定是固定的y坐标位置。