java-client 升级后没法使用swipe方法,使用TouchAction进行封装
Posted Elvis_lfc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java-client 升级后没法使用swipe方法,使用TouchAction进行封装相关的知识,希望对你有一定的参考价值。
import java.time.Duration;import io.appium.java_client.TouchAction;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.touch.WaitOptions;
import io.appium.java_client.touch.offset.PointOption;
public class SwipeClass
static Duration duration=Duration.ofSeconds(1);
public void swipeToUp(AndroidDriver driver)
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
TouchAction action1=new TouchAction(driver).press(PointOption.point(width/2, height*3/4)).waitAction(WaitOptions.waitOptions(duration))
.moveTo(PointOption.point(width/2, height/4)).release();
action1.perform();
public void swipeToDown(AndroidDriver driver)
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
TouchAction action2=new TouchAction(driver).press(PointOption.point(width/2, height/4)).waitAction(WaitOptions.waitOptions(duration))
.moveTo(PointOption.point(width/2, height*3/4)).release();
action2.perform();
public void swipeToLeft(AndroidDriver driver)
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
TouchAction action3=new TouchAction(driver).press(PointOption.point(width*3/4, height/2)).waitAction(WaitOptions.waitOptions(duration))
.moveTo(PointOption.point(width/4,height/2)).release();
action3.perform();
public void swipeToRight(AndroidDriver driver)
int width = driver.manage().window().getSize().width;
int height = driver.manage().window().getSize().height;
TouchAction action4=new TouchAction(driver).press(PointOption.point(width / 4, height / 2)).waitAction(WaitOptions.waitOptions(duration))
.moveTo(PointOption.point(width*3/4,height/2)).release();
action4.perform();
以上是关于java-client 升级后没法使用swipe方法,使用TouchAction进行封装的主要内容,如果未能解决你的问题,请参考以下文章
升级 SpringBoot 2.6.x 版本后,Swagger 没法用了
升级 SpringBoot 2.6.x 版本后,Swagger 没法用了
java-client 8.0.0 中不存在 MobileElement
Jaeger-Opentracing的Java-client