zoukankan      html  css  js  c++  java
  • appium 滑动,不使用swipe,使用新TouchAction 转载 https://blog.csdn.net/Elvis_lfc/article/details/80776945

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


    }

  • 相关阅读:
    Hdu 3564 Another LIS 线段树+LIS
    利用ESLINT进行js 语法检查,以及局部安装时遇到的一些坑
    操作系统杂谈
    算法杂谈
    前端杂谈
    操作系统复习
    vue之——从彩笔的进步之路
    一丢丢学习之webpack4 + Vue单文件组件的应用
    计蒜客 2017复赛 百度地图导航
    electron打包之真的恶心
  • 原文地址:https://www.cnblogs.com/lixiaowei395659729/p/10063614.html
Copyright © 2011-2022 走看看