標籤: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服務端聯調出現的問題解決辦法