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

    }

  • 相关阅读:
    JS 字符串全部替换 ,replace (/ /g,'')
    C#中的延时加载Lazy(Of T)
    并发程序报错:ORA01007: variable not in select list(选择列表中没有变量) 以及相关动态指针写法
    【转】PLSQL中显式Cursor、隐式Cursor、动态Ref Cursor区别
    Shell 学习
    常用SQL和链接
    关于ra_customer_trx_lines_all 应收发票行
    translate和replace 的区别
    应收帐款汇总
    在Users里已经赋予了Responsibility,登陆以后无法看到新增加的Responsibility解决办法
  • 原文地址:https://www.cnblogs.com/yatou-de/p/13743544.html
Copyright © 2020-2023  润新知