0
votes

I am trying to do some UITests with Appium 1.11.1 on iOS Simulator and Swipe is not working

driver connexion looks fine.. I can test driver.reloadApp() and it's working

I have tried some examples found in stack overflow about 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);
}

and the test is passed but nothing happens in the screen

I tried this solution also https://stackoverflow.com/a/50388361/7406696 and it's not working with my simulator

My pom.xml is this one

<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>
1

1 Answers

0
votes

Finally worked removing waitOptions and changing from press() to 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);  
}