TouchAction to swipe 不工作 iOS 模拟器 - Appium Java

TouchAction to swipe not working iOS Simulator - Appium Java

我正在尝试在 iOS 模拟器上使用 Appium 1.11.1 进行一些 UITests 并且滑动不工作

驱动程序连接看起来很好..我可以测试 driver.reloadApp() 并且它正在工作

我尝试了一些在堆栈溢出中找到的关于 TouchActions 的示例

public static void swipeHorizontal(MobileDriver driver, double startPercentage, double finalPercentage, int duration) throws Exception {
      Dimension size = driver.manage().window().getSize();
      int height =  (int) (size.height/2);
      int startPoint =  (int) (size.getWidth() * startPercentage);
      int endPoint =  (int) (size.getWidth() * finalPercentage);
      new TouchAction(driver).press(new PointOption().point(height, startPoint)).waitAction(new WaitOptions().waitOptions(Duration.ofMillis(duration))).moveTo(new PointOption().point(height, endPoint)).release().perform();
    }

@Test.....{
      swipeHorizontal(driver, 0.80, 0.20, 5);
}

测试通过但屏幕上没有任何反应

我也试过这个解决方案 但它不适用于我的模拟器

我的pom.xml就是这个

<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>5.0.4</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>io.appium</groupId>
        <artifactId>java-client</artifactId>
        <version>7.0.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
        <scope>test</scope>
    </dependency>
 </dependencies>

终于成功删除 waitOptions 并将 press() 更改为 longPress()

public static void swipeHorizontal(AppiumDriver driver, double startPercentage, double finalPercentage) throws Exception {
      Dimension size = driver.manage().window().getSize();
      int anchor =  (int) (size.height/2);
      int startPoint =  (int) (size.width * startPercentage);
      int endPoint =  (int) (size.width * finalPercentage);
      new TouchAction(driver).longPress(new PointOption().point(startPoint, anchor)).moveTo(new PointOption().point(endPoint, anchor)).release().perform();
  }


@Test..... {
      swipeHorizontal(driver, 0.80, 0.20);  
}