• appium(五)常用方法


    1、在使用appium时,经常会用到adb命令,我们可以使用以下方法来调用adb,如下例调用adb滑动屏幕

    String cmd="cmd /c start adb shell input swipe X0,Y0,X1,Y1,TIME ";
    Runtime.getRuntime().exec(cmd);

    2、使用appium的方法,使用坐标进行滑动屏幕

            TouchAction action = new TouchAction(driver);
            //设置起点和终点
            PointOption pressPoint=PointOption.point(x, y);
            PointOption movePoint=PointOption.point(x1, y1);
            //滑动
            action.longPress(pressPoint).moveTo(movePoint).release().perform();

    3、使用appium的方法,使用坐标点击

            TouchAction action = new TouchAction(driver);
            PointOption pressPoint=PointOption.point(x, y);
            //点击
            action.tap(pressPoint).release().perform();

    4、使用appium的方法,长按某个坐标

            TouchAction action = new TouchAction(driver);
            PointOption pressPoint=PointOption.point(x, y);
            //设置长按的时间
            Duration last = Duration.ofSeconds(t);
            WaitOptions wait= WaitOptions.waitOptions(last);
            //长按坐标
            action.longPress(pressPoint).waitAction(wait).perform();

    5、使用appium的方法,长按某个元素

            Duration last = Duration.ofSeconds(t);
            TouchAction action = new TouchAction(driver);
            //定位到一个元素,并且在该元素上长按指定的时长
            action.longPress(LongPressOptions.longPressOptions().withElement(ElementOption.element(driver.findElementByXPath(xpath))).withDuration(last)).waitAction(WaitOptions.waitOptions(last)).perform();

    6、appium的其他方法,可以参考 TouchAction 的源码

  • 相关阅读:
    注册时正则验证及提示demo
    密码的修改(首先获取该用户的id,原密码判断是否一致,新密码和再次输入密码判断是否一样)
    变量和常量
    python入门基础
    python2设计一个用户登录
    python2与python3中input的区别
    python日记----2017.7.26
    python日记----2017.7.25
    python日记----2017.7.24
    python日记----2017.7.20
  • 原文地址:https://www.cnblogs.com/yjh1995/p/12154226.html
Copyright © 2020-2023  润新知