appium中點擊操作

來源:互聯網
上載者:User

標籤:comment   port   類比   imp   res   arc   post   start   舉例   

1.方法一,使用tap

tap有兩個參數,元素位置和點擊期間。

一般文法是這樣的tap((x1,y1),(x2,y2)],100), 我們通過手機百度中,利用tap方法來點擊網路攝影機按鈕來舉例。

1.元素定位

記住上面的元素座標,下面需要用到。

2.tap代碼實現

  1. import os  
  2. import time  
  3. from appium import webdriver  
  4.   
  5. desired_caps ={ ‘platformName‘: ‘Android‘,  
  6.                 ‘platformVersion‘: ‘6.0.1‘,  
  7.                 ‘deviceName‘: ‘KIW-AL10‘,  
  8.                 ‘noReset‘: True,  
  9.                 ‘appPackage‘: ‘com.baidu.searchbox‘,  
  10.                 ‘appActivity‘: ‘com.baidu.searchbox.SplashActivity‘,  
  11.                 ‘unicodeKeyboard‘: True,  
  12.                 ‘resetKeyboard‘: True  
  13.                 }  
  14.   
  15. driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps)#啟動app  
  16. time.sleep(3) #app啟動後等待3秒,方便元素載入完成  
  17. #類比手指點擊操作  
  18. driver.tap([(918,413),(1026,521)], 100)  

解釋:上面tap方法中位置的元素點座標是通過ui automator viewer擷取,期間100是指100毫秒。

以上文章來源:

http://blog.csdn.net/u011541946/article/details/77986197

 

 

appium中點擊操作

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.