Appium基礎——one demo

來源:互聯網
上載者:User

標籤:tail   androi   white   ace   shel   blog   分享圖片   android   tomato   

啟動模擬器,啟動appium android avd啟動模擬器管理選擇一個版本啟動 安裝appium-client直接pip install appium-python-client安裝簡單指令碼:計算機 參數: platformName = Android   #android或iOSplatformVersion = 4.2  #android的版本號碼deviceName = Android Emulator  #模擬器或 裝置idappPackage = com.hunbohui.yingbasha #apk包名appActivity = .component.menu.HomeActivity #啟動名webdriver.Remote(‘http://localhost:4723/wd/hub’,Capabilities)第一個參數固定寫就ok,如果使用遠端機器做測試,localhosts改成對應機器的ip即可 如何擷取 appPackage和appAcitvity:1.擷取appPackage 這個其實就是安裝包的名稱在android檔案夾tools下找到uiautomatorviewer並開啟,在連結手機的情況下,點擊:

 

這樣就擷取了當前螢幕在右下方Detail中可以找到package為com.android.calculator2,這個就是包名2.擷取appAcitvitycmd中輸入:adb shell dumpsys activity activities 找到這個,用 / 分割,前面是package,後面是appAcitvity 如何擷取裝置號deviceNamecmd下運行adb devices這個就是裝置號  
# encoding=utf-8from appium import webdriver desired_caps = {}desired_caps[‘platformName‘] = ‘Android‘desired_caps[‘platformVersion‘] = ‘4.4.2‘desired_caps[‘deviceName‘] = ‘Android Emulator‘desired_caps[‘appPackage‘] = ‘com.android.calculator2‘desired_caps[‘appActivity‘] = ‘.Calculator‘ driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘, desired_caps) driver.find_element_by_name("1").click()driver.find_element_by_name("5").click()driver.find_element_by_name("9").click()driver.find_element_by_name("delete").click()driver.find_element_by_name("9").click()driver.find_element_by_name("5").click()driver.find_element_by_name("+").click()driver.find_element_by_name("6").click()driver.find_element_by_name("=").click() driver.quit()

 

  

 

  

Appium基礎——one demo

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.