Swipe functionality working locally but fails on device farm

237 views Asked by At

I am trying to run a simple swipe function for an iOS app. The swipe functionality that I'm using is something like this:

 public static void swipe (AppiumDriver<?> driver, WebElement element, String direction ) throws Exception {
    int startX = element.getLocation().getX();
    int startY = element.getLocation().getY();
    int endX = element.getLocation().getX();
    int endY=element.getLocation().getY();

    switch (direction){
    case  "left":
        System.out.println(startX);
        startX += element.getSize().getWidth();
        endX = -(element.getSize().getWidth());
        break;
    case "right":
        startX = 0;
        endX +=element.getSize().getWidth();
        break;
    case "up":
        startY += element.getSize().getHeight();
        endY =  -element.getSize().getHeight();
        break;
    case "down":
        endY += driver.manage().window().getSize().getHeight();
        break;
    default:
        throw new Exception("invalid direction, must be left/right/up/down");
    }
    //driver.swipe(startX, startY, endX, endY, 1000);
 new TouchAction(driver).press(startX, startY).waitAction(1000).moveTo(endX, 
       endY).release().perform();
    System.out.println(startX +" " + startY+ " " + endX+ " " +endY);

}

The default capabilities I'm using locally are:

"platformName": "iOS"
"platformVersion": "10.3"
"automationName": "Appium"
"deviceName": "iPhone 7"

I have tried with the same desired capabilities locally and its working fine on the simulator. I am running it on the same device(i in the device farm.

I am also using the Appium v1.6.5 locally as well as in device farm.

1

There are 1 answers

1
jmp On

Do not set your desired capabilities for device farm. It will not use them and in expected things happen when doing that.

https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app/blob/master/src/test/java/Tests/AbstractBaseTests/TestBase.java#L60

Try not setting them and see if that helps. Let me know what happens.

Best regards James