zoukankan      html  css  js  c++  java
  • 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 的源码

  • 相关阅读:
    QTextStream 居然接受FILE*这样的传统参数
    基于IOCP的高速文件传输代码
    tornado web框架
    Kaggle入门
    NET Core 介绍
    Wireshark
    设计和应用分布式调用跟踪系统
    Visual Studio Code和Docker开发asp.net core和mysql应用
    背单词
    多环境开发
  • 原文地址:https://www.cnblogs.com/yjh1995/p/12154226.html
Copyright © 2011-2022 走看看