關於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); 單位為毫秒

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM