Mobile: dragFromToForDuration duration works like delay

Hi,

I am testing the mobile: dragFromToForDuration with Appium v2.0.0-beta.44 and with the latest Java-Client 8.2.0 (did not test with older versions).

And what I see is whatever value I set to the duration argument it does the same speed drag but the delay before the drag changes with the value in seconds.

POST: {{baseURL}}/{{sessionID}}/execute/sync

{
    "script": "mobile: dragFromToForDuration",
    "args": [
        {
            "duration": "1",
            "fromY": 627, "toY": 350,
            "fromX": 404, "toX": 404
        }
    ]
}

For example: if the duration is 5, it does nothing 5 seconds and does the same fast drag what it does with duration 0. The fast drag performs like a swipe which is not accurate for some cases.

The dragging coordinates are correct I tested it on a drawing app, but the “duration” seems doesn’t behave as expected, it behaves like a delay before dragging but not as a duration of the dragging process.

Am I missing something in the caps or settings, or else?

This is important as having the drag as a swipe is not accurate and affects on overall tests robustness.

Thanks

If you look at the description of duration in the link you provided it says:

Float number of seconds in range [0.5, 60]. How long the tap gesture at starting drag point should be before to start dragging

It seems to be working as advertised. This parameter is not about the speed of the drag, but rather the time of the initial click and hold before drag.

Apple documentation embedded in your link seems to confirm this:

Clicks and holds an element for a duration you specify and drags it to the other element.

Oh, my mistake, sorry, and thank you for your time and the answer.
So it is actually and officially delay the a duration. I think the word “duration” confused me to skip the details int the description, If “delay” there will not be that confusion.

is there a way for “slow” drag?

Thank you, Regards

Yes, this is possible after Xcode 12 by calling https://developer.apple.com/documentation/xctest/xcuielement/3551693-pressforduration?language=objc

Unfortunately there is no XCUITest driver wrapper for this particular call yet, but I could add it sometimes soon.

As a workaround you could create your own gesture by using W3C actions. Check https://appiumpro.com/editions/29-automating-complex-gestures-with-the-w3c-actions-api and https://github.com/appium/appium-xcuitest-driver/blob/master/docs/ios/actions.md

1 Like

Added it in the recent xcuitest driver version: https://github.com/appium/appium-xcuitest-driver#mobile-dragfromtowithvelocity

2 Likes

Ammmmaaaaazing :clap: :clap: :clap: :clap: :clap:

You are super!

The new command is powerful, flexible and I am sure will be very useful, has no confusions in argument names and has clear description.

Thank you for your operative support, Master.

1 Like