I heard that Appium java-client new version does not support swipe, the internet did not find the complete available, today just sorted out with the Touchaction replacement script, record, hehe ...
Importjava.time.Duration;Importio.appium.java_client. touchaction;ImportIo.appium.java_client.android.AndroidDriver;Importio.appium.java_client.touch.WaitOptions;Importio.appium.java_client.touch.offset.PointOption; Public classSwipeclass {StaticDuration Duration=duration.ofseconds (1); Public voidSwipetoup (androiddriver driver) {intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height; Touchaction Action1=NewTouchaction (Driver). Press (Pointoption.point (WIDTH/2, HEIGHT*3/4) . Waitaction (waitoptions.waitoptions (Duration)). MoveTo (Pointoption.point (Width/2, HEIGHT/4) . Release (); Action1.perform (); } Public voidSwipetodown (androiddriver driver) {intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height; Touchaction Action2=NewTouchaction (Driver). Press (Pointoption.point (WIDTH/2, HEIGHT/4) . Waitaction (waitoptions.waitoptions (Duration)). MoveTo (Pointoption.point (Width/2, HEIGHT*3/4) . Release (); Action2.perform (); } Public voidswipetoleft (androiddriver driver) {intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height; Touchaction Action3=NewTouchaction (Driver). Press (Pointoption.point (WIDTH*3/4, HEIGHT/2) . Waitaction (waitoptions.waitoptions (Duration)). MoveTo (Pointoption.point (Width/4,height/2) . Release (); Action3.perform (); } Public voidswipetoright (androiddriver driver) {intwidth =driver.manage (). window (). GetSize (). width; intHeight =driver.manage (). window (). GetSize (). Height; Touchaction Action4=NewTouchaction (Driver). Press (Pointoption.point (WIDTH/4, HEIGHT/2) . Waitaction (waitoptions.waitoptions (Duration)). MoveTo (Pointoption.point (Width*3/4,height/2) . Release (); Action4.perform (); }}
Appium, row down, left and right stroke