Swipe action is not performing on WMA Android app

Hi Team,

we are using leapwork mobile automation and through that we tried to perform the swipe right operation on the WMA app

Steps to perform.

Open the app

click on demo mode

click on Purchase Receive, in this window we are performing swipe right .

Below is the code which we are using

var inputDevice = new PointerInputDevice(PointerKind.Touch, MobileConstants.SwipeTouch);
var swipeActionSequence = new ActionSequence(inputDevice, 0);
var swipeDuration = GetSwipeDuration();

var center = GetElementCenter();
executor.Log.Debug($“Element center calculated at ({center.X}, {center.Y}).”);

var destination = GetTouchDestination(center);
executor.Log.Debug($“Touch destination calculated at ({destination.X}, {destination.Y}).”);

//Creating swipe sequence
swipeActionSequence.AddAction(inputDevice.CreatePointerMove(CoordinateOrigin.Viewport, center.X, center.Y, TimeSpan.Zero));
swipeActionSequence.AddAction(inputDevice.CreatePointerDown(PointerButton.TouchContact));

swipeActionSequence.AddAction(inputDevice.CreatePause(TimeSpan.FromMilliseconds(MoveToDelayMilliseconds)));
swipeActionSequence.AddAction(inputDevice.CreatePointerMove(CoordinateOrigin.Viewport, destination.X, destination.Y, swipeDuration));
swipeActionSequence.AddAction(inputDevice.CreatePointerUp(PointerButton.TouchContact));

//Performing swipe action sequence
executor.Driver.PerformActions(new List { swipeActionSequence });
executor.Log.Debug(“Swipe actions performed successfully.”);

here for swipe, we tried to pass custom swipe value to 50, sometimes it works as expectd and sometimes it does not work.

Kindly assist me.

FYI @mykola-mokhnach @Aleksei @wreed

try:

1 make sure animation stopped before swipe. e.g. disable animation on device or in driver capabilities or add delay after previours swipe happens.

2 enable see touches and coordinates on Android device and check when and how actually swipe happens.

3 when swipe fails → try manually with same touches. I often saw that some app areas are not sensibly and swipe just not starting.

Hi, thank you for the reply. The problem is that out of 10 times, it swipes perfectly fine for 3-4 times. but not able to get to know why it fails rest of the time. I tried to compare the coordinates too, that are also same but still fails

Try to apply a mobile gesture as a possible alternative: appium-uiautomator2-driver/docs/android-mobile-gestures.md at master · appium/appium-uiautomator2-driver · GitHub

also can try pure UIAutomator2 commands → https://developer.android.com/reference/androidx/test/uiautomator/UiScrollable