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 的源码

  • 相关阅读:
    Nginx URL后面不加斜杠301重定向
    Jenkins 配置 Node.js 项目
    在 Linux 上搭建IntelliJ IDEA license server服务器
    Vue 使用细节收集
    sinopia 搭建记录
    cli 开发记录
    Cgroup(一)简介
    Kubernetes (一)POD驱逐
    RabbitMQ(五)镜像队列
    RabbitMQ(四)队列结构
  • 原文地址:https://www.cnblogs.com/yjh1995/p/12154226.html
Copyright © 2011-2022 走看看