0
votes

I’m trying to perform a circle gesture operation on mobile device screen using appium. I tried with swipe(), press("args").moveTo("args") and also tried using javascript executor method also. But not able to perform the circle gesture operation on mobile screen for iOS.

Need to perform this circle gesture operation without loosing the touch in middle while performing this action from first point to last point.

Is there any tool like AutoIT or Sikuli to perform this above gesture operation on mobile devices and can be executed in appium scripts using java in Mac.

2

2 Answers

1
votes

For those looking for a quick solution, here is my implementation based on the other comments in this thread:

public void SwipeArc(double centerX, double centerY, double radius, double startDegree, double degrees, int steps)
{
    //interpolate along the circumference of the circle
    double angle = degrees / steps;
    double prevX = centerX + radius * Math.Cos(startDegree * Math.PI / 180F); ;
    double prevY = centerY + radius * Math.Sin(startDegree * Math.PI / 180F);

    TouchAction circleTouch = new TouchAction(_Driver); //Your appium driver object here
    circleTouch.Press(prevX, prevY);

    for(int i = 1; i <= steps; ++i)
    {
        double newX = centerX + radius * Math.Cos((startDegree + angle * i) * Math.PI / 180F);
        double newY = centerY + radius * Math.Sin((startDegree + angle * i) * Math.PI / 180F);

        double difX = newX - prevX;
        double difY = newY - prevY;
        circleTouch.MoveTo(difX, difY);

        prevX = newX;
        prevY = newY;
    }

    circleTouch.Release();
    circleTouch.Perform();
}

This solution assumes the Appium server is expecting relative coordinates for each step, I'm not sure if this is the case for all Appium server versions.

0
votes

Use touch actions! I tried it on iOS and android real devices, it works fine. But you may need to play around a bit to get the right sets of coordinates and move parameters.