Do we need to create obj for every method in touch action? unable to use same touch ref variable for calling second method

Hi ,

I have created touch action class object for tapping an element , next i would like perform long press , but script failing if i use same reference variable of Touch class. If i create second object its working fine.

Failed :

TouchAction touch=new TouchAction(driver);
touch.tap(“element1”)).release().perform(); // tap

touch.press(longpress).waitAction(3000).release().perform(); // long press …here script failed

Working code

TouchAction touch1=new TouchAction(driver);
touch1.tap(“element1”)).release().perform(); // tap

TouchAction touch2=new TouchAction(driver);

touch2.press(longpress).waitAction(3000).release().perform(); //long press

@skmvali123
According to this page, the TouchAction is valid only for a single usage. You should use MultiTouchAction.