Acquiring basic parameters
1, set the IP and port, start Appium.
2, connect the phone (I used here is the simulator)
Get to the phone IP, the IP port is the value of the following deviceName.
3, get appPackage \ appActivity
aapt dump badging apk file path
Appium installation starts APP
-
This step can be installed to start APP, installed directly start.
-
Note that if you use this Genymotion may report Failure [INSTALL_FAILED_NO_MATCHING_ABIS] This is because the simulator really
x86
running on the processor, and the phones are generallyRAM
architecture, so you had to brush into the simulatorARM
for the job (is not the reason I do not know, we all say Baidu ~), the solution is to download the corresponding Genymotion-ARM -Translation_v1.1.zip compression package, and then pull into the simulator, you can restart the simulator (is not feeling very simple, it is worth Note that some smaller partners such as I do occasionally like to use the Chinese folder, so attention is being given this, it is best placed in the root directory, I offer here a few Android version corresponding zip package, it is online hard to find, ghosts know how much I downloaded the software .... sticking extraction code: 5pl4)
# - * - Coding: UTF-. 8 - * - __author__ = ' Luke ' from appium Import the webdriver # dictionary definitions, configuration appium desired_caps = { ' PlatformName ' : ' the Android ' , # system ' platformVersion ' : ' 5.0 ' , # version ' deviceName ' : ' 192.168.184.107:5555 ' , # I have here is an analog machine ' App ': R & lt ' D: \ Android \ zalo.apk ' , # APK installation package position ' appPackage ' : ' com.zing.zalo ' , # APK the package, by aapt find command ' appActivity ' : ' com.zing.zalo. ui.SplashActivity ' , # APK's launcherActivity, look through aapt command ' NoReset ' : True, # important parameter, = True restore the default values, = False (default value) every time to enter (format from the state just installed the app state), and the like may be displayed to the intro } Driver = webdriver.Remote ( ' http://127.0.0.1:4723/wd/hub ' , desired_caps) # Connection appium, and parameters (dictionary) incoming
Element location identification tool
-
Identify common elements and tools uiautomator monitor, I selected a monitor other Baidu own it ~
-
This tool tools android SDK folder under the (local address D: \ android \ android-sdk-windows \ tools), click start to use.
Appium Select Location (element)
This can JS, jQuery selector appreciated mainly comprising ID, Class, centent-desc, text, xpath to locate.
By id
positioning element (find_element_by_id)
-
Elements of resource-id
-
The only value that identifies the element (id sometimes not the only)
-
The generally preferred positioning id
driver.find_element_by_id ( ' com.zing.zalo: the above mentioned id / btnLogin ' ) .click () # the Click event for clicks
By class_name
positioning element
By content-desc
positioning element
By text
positioning element
By xpath
positioning element