python用戶端和Appium服務端聯調出現的問題解決辦法

來源:互聯網
上載者:User

標籤:image   cep   for   jdk   ppp   activity   自動化測試   cannot   appium   

按照安裝文檔搭建完移動端自動化測試環境,包括:SDK、JDK、Node.js、Appium及用戶端後,appium-doctor可以成功的檢測到各配套版本。如:

可是,運行from appium import webdriver出錯,上報:ImportError: cannot import name InvalidArgumentException錯誤。

我查看C:\Python27\Lib\site-packages\appium\webdriver\webdriver.py檔案,發現該檔案引用的是from selenium import webdriver

於是,我把代碼中的這項from appium import webdriver改成from selenium import webdriver,查看Appium服務發現能夠聯調成功。

可是運行代碼的時候,探索服務端上報如下錯誤:Android devices must be of API level 17 or higher.

 

查看我的模擬器,發現版本為:

 

於是果斷再增加一個API17版本的類比機,

再運行測試指令碼:

#coding=utf-8
from appium import webdriver

desired_caps = {}
desired_caps[‘platformName‘] = ‘Android‘
desired_caps[‘platformVersion‘] = ‘4.4.2‘
desired_caps[‘deviceName‘] = ‘192.168.54.101:5555‘
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("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()
成功串連到伺服器啟動類比手機的計算機功能做自動化測試。

 


 

python用戶端和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.