How to Hold without Duration

Hello,

I currently have 2 methods to handle touch actions of hold and release

    public static void HoldLongPressByCoordinates(int x, int y, int waitTime = 3)
    {
        Thread.Sleep(TimeSpan.FromSeconds(waitTime));
        TouchAction touchActionHold = new TouchAction(_driver);
        touchActionHold.LongPress(x, y).Perform();
    }

    public static void ReleaseLongPressByCoordinates()
    {
        touchAction.Release().Perform();
    }

TouchActions are obviously deprecated with newer versions.
From what i saw I can use it this way

var js = (IJavaScriptExecutor)_driver;
var scriptArgs = new Dictionary<string, object>
{
{ “x”, x },
{ “y”, y },
{ “duration”, 30000 } // Duration in milliseconds
};
js.ExecuteScript(“mobile: longClickGesture”, scriptArgs);

But, I cant seem to find a way to hold without a duration so i could perform other actions while hold is still active.

Is there any other way to make it work like i had with the touch actions?

1 Like