关于appium中的TouchAction的用法

时间:2019-04-11 00:53:40   收藏:0   阅读:360

1.按压press

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

press(WebElement el, int x, int y)        

比如TouchAction(driver).press(x=0,y=308).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); 单位为毫秒

 

原文:https://www.cnblogs.com/wind666/p/10687160.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!