zoukankan      html  css  js  c++  java
  • 关于appium中的TouchAction的用法

    1.按压press

    开始按压一个元素或坐标点(x,y)。通过手指按压手机屏幕的某个位置。

    press(WebElement el, int x, int y)        

    比如TouchAction(driver).press(x=0,y=308).release().perform()     

    • release() 结束的行动取消屏幕上的指针。释放,相当于松手

    • Perform() 执行的操作发送到服务器的命令操作。

    2.长按控件

    longPress(WebElement el, int x, int y, Duration duration)

    开始按压一个元素或坐标点(x,y)。 相比press()方法,longPress()多了一个入参,既然长按,得有按的时间吧。duration以毫秒为单位。1000表示按一秒钟。其用法与press()方法相同。

    1.  TouchAction action = new TouchAction(driver);
    2.  action.longPress(names.get(200),1000).perform().release();
    3.  action.longPress(200 ,200,1000).perform().release();

    3.点击控件tap

    tap(WebElement el, int x, int y)

    1. TouchAction action = new TouchAction(driver);
    2.  action.tap(names.get(200)).perform().release();
    3.  action.tap(200 ,200).perform().release();

    4.移动 moveto

    moveTo(WebElement el, int x, int y)
    1. TouchAction action = new TouchAction(driver);
    2.  action.moveTo(names.get(200)).perform().release();
    3.  action.moveTo(200 ,200).perform().release();

    5.暂停 wait()

    action.wait(1000); 单位为毫秒

  • 相关阅读:
    上篇用到的matcher函数
    lambdaj学习
    Redis高级应用——2
    Redis入门
    从gitee 下载代码到本地
    CSS中对图片(background)的一些设置心得总结
    nodejs 安装Ionic 和cordova
    Spring MVC内容协商机制详解
    基于Servlet3.0的编程式SpringMVC实例详解
    基于Junit的Spring集成测试方法
  • 原文地址:https://www.cnblogs.com/wind666/p/10687160.html
Copyright © 2011-2022 走看看