Today, using the Appium 6.1.0 Java client, it is found that long press longpress (element) is not available. The following code is available in the 5.0.4 version,
Webelement notedelete = Driver.findelementbyxpath ("//android.widget.listview[@resource-id= ' android:id/list ']/ ANDROID.WIDGET.RELATIVELAYOUT[1] "); int x = notedelete.getlocation (). GetX (); int y = notedelete.getlocation (). GetY (); New touchaction (driver); = Duration.ofmillis (+); // Press for 1 seconds action.press (x, y). Waitaction (Duration). moveTo (x, y). Release (). perform (); The way a long press and slide are applicable to action.longpress (notedelete). Release (). perform (); Way two long press
This code again 6.1.0 is unusable, and finally install the API prompt, modify the code as follows, the actual application of the selected method can be
Webelement notedelete = Driver.findelementbyxpath ("//android.widget.listview[@resource-id= ' android:id/list ']/ ANDROID.WIDGET.RELATIVELAYOUT[1] "); intx =notedelete.getlocation (). GetX (); inty =notedelete.getlocation (). GetY (); Duration Duration= Duration.ofmillis (2000); Touchaction Action=Newtouchaction (driver); Action.longpress (Pointoption.point (x, y)). Release (). perform (); //Long Pressaction.press (Pointoption.point (x, y))//Long Press and swipe are available. Waitaction (waitoptions.waitoptions (Duration)). MoveTo (Pointoption.point (x, y)) . Release (). perform ();
Java appium Client 6.1.0android Long Press and swipe changes