After installing the Mobile Automation test environment in accordance with the installation documentation, including: SDK, JDK, node. js, Appium, and client, Appium-doctor can successfully detect each companion version. Such as:
However, the run from Appium import webdriver error, escalation: Importerror:cannot Import name invalidargumentexception error.
I view the C:\Python27\Lib\site-packages\appium\webdriver\webdriver.py file and found that the file refers to the from selenium import Webdriver
So, I changed the code from Appium import Webdriver to the From selenium import webdriver, view Appium Service discovery to be successful.
However, when running the code, we found that the server reported the following error: Android devices must be of the API level or higher.
View my emulator and discover the version as:
And then decisively add a API17 version of the simulator,
Run the test script again:
#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 ()
Successfully connect to the server to start the analog phone's calculator function to do automated testing.
Solution to problems with Python client and Appium service end-of-union