Selenium 3.0.1 how to release a longPress action and how long does it execute?

Viewed 32

I'm using Selenium version 3.0.1. Java Client.

I want to use the "longPress" action from the org.openqa.selenium.interactions.touch.TouchActions package. However, I also want to long press a web element for a specefic amount of time and the longPress method does not give me this option. So I have two questions here:

1- How long does the longPress method touches on an element? Does it keep pressing on it until I call the release() method? 2- What alternative do I have to be able to long press on an element for a specific amount of time? Note that by "long press" I mean by touching the element and emitting a touch event, not clicking.

I tried the below using the release() method provided by Selenium:

touchAction.longPress(element).build().perform();
Thread.sleep(3000);
touchAction.release();

I expect the above code to longPress for approximately 3 seconds and then release this gesture from the element but it threw a NullPointerException because there is no "Mouse" instance object which makes sense since I am using TouchActions.

1 Answers
        touchAction.longPress(status,10000).build().perform();
        Thread.sleep(3000);
        touchAction.release();

I have set 10 seconds you can change it.

Related