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

  • 相关阅读:
    以JPanel为基础实现一个图像框
    扩展JButton实现自己的图片按钮
    箴言录2014年4月22日
    搜集整理一些Cron表达式例子
    长途旅行感悟
    箴言录2014年4月19日
    Linux下显示硬盘空间的两个命令
    Linux命令复习和练习_02
    Dash:程序员的的好帮手
    Linux的桌面环境gnome、kde、xfce、lxde 等等使用比较
  • 原文地址:https://www.cnblogs.com/yjh1995/p/12154226.html
Copyright © 2011-2022 走看看