First, the Environment configuration chapter
Configure on Windows
1) There are options when installing node. JS (http://nodejs.org/download/) installation, remember to add environment variables to path path
2) using NPM to install Appium, run cmd input npm install-g appium (some friends reaction to run NPM under CMD is invalid, if so please add the Nodejs directory to the user variable path to restart CMD to refer to the Post:/http blog.csdn.net/iispring/article/details/8023319), such as:
3) Download Install ANDROID SDK, set environment variables to point to android_home%\tools and% Android_home%\platform-tools
4) Install the JDK and set the JAVA_HOME environment variable
8) Run the cmd input appium-doctor to check if your environment is configured properly.
The overall environment variable is configured, but the next step is to configure the Python+selenium installation.
Second, python+selenium installation configuration:
Look at my previous article, http://www.cnblogs.com/test-of-philosophy/articles/4322918.html.
Three, Appium start the article
Since my test is connected to the real machine, it is necessary to obtain the UDID number of the real machine through the ADB devices-l command, the detailed steps are as follows:
1) Real Machine (Android version 4.2.2) connected to PC via USB, driver installed, open USB debug mode
2) Enter Appium-a 127.0.0.1-p 4723 in cmd (-a means that ip,-p represents the port, you can view more commands by Appium-h)
3) If the Appium service has been successfully started as shown, note that this window is not closed because the service is closed by Appium service, the subsequent process cannot be executed, and this window is also the Log Output window for troubleshooting.
Iv. Code Execution
Example: Install an app
Import OS
Import UnitTest
From Appium import Webdriver
From time import sleep
# Returns ABS Path relative to this file and not CWD
PATH = Lambda P:os.path.abspath (
Os.path.join (Os.path.dirname (__file__), p)
)
Class Contactsandroidtests (UnitTest. TestCase):
def setUp (self):
Desired_caps = {}
desired_caps[' platformname ' = ' Android '
desired_caps[' platformversion '] = ' 4.2.2 '
desired_caps[' devicename ' = ' Android Emulator ' # if the real machine, just write the type of the real machine, such as: HUAWEI gt750-t00
desired_caps[' app ' = PATH (
' d:\\workspace\\appium\\app\\example.apk ' # This is the way to put the app
)
desired_caps[' apppackage '] = ' com.example.example '
desired_caps[' appactivity '] = '. Exampleactivity '
Self.driver = Webdriver. Remote (' Http://localhost:4723/wd/hub ', desired_caps)
def tearDown (self):
Self.driver.quit ()
if __name__ = = ' __main__ ':
Suite = UnitTest. Testloader (). Loadtestsfromtestcase (contactsandroidtests)
UnitTest. Texttestrunner (verbosity=2). Run (Suite)
Window under the Appium+python environment building