zoukankan      html  css  js  c++  java
  • appium java-client 5.0以后移除了swipe方法,也就是无法使用driver.swipe()了

    感谢这位巨人
    https://www.cnblogs.com/tianyumuhe/p/9123350.html

    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();
        }

    }

  • 相关阅读:
    html提交表单到Servlet
    Kubernetes(k8s)概念学习、集群安装
    Kubernetes(k8s)入门学习
    Spring Boot整合Scheduled定时任务器、整合Quartz定时任务框架
    Maven项目Run As无Run On Server的解决方法
    SpringBoot异常处理五种方式、Junit单元测试、热部署
    SpringBoot整合整合jsp、整合freemarker、整合Thymeleaf
    SpringBoot整合Servlet、Filter、Listener、访问静态资源、文件上传
    Vue前端路由
    Vue前端交互
  • 原文地址:https://www.cnblogs.com/yatou-de/p/13743544.html
Copyright © 2011-2022 走看看