get app Info:
from appium import webdriver
desired_caps = {}
desired_caps [ ' PlatformName ' < span> = < span> ' Android ' Span class= "PLN" > # what kind of mobile platform
desired_caps [ ' platformversion ' < span> = < span> ' 4.2 ' #设备版本号
desired_caps [ ' devicename ' < span> = < span> Android Emulator ' &NBSP; Span class= "com" > #设备是模拟机
desired_caps [ ' Apppackage ' < span> = < span> ' Com.android.calculator2 ' &NBSP; #待测试的app的java package
desired_caps [ ' appactivity ' < span> = < span> #待测试的app的activity名字
Driver=Webdriver.Remote(' Http://localhost:4723/wd/hub ',Desired_caps) #
discussion: Webdriver. Remote is actually a subclass of the native Webdriver, and the first parameter of the remote () constructor needs to display the port that the specified Appium server listens on
1,monitor.bat(get the app's package&activity)
This tool can help us find the content-description of the Android control for future find_element_by_accessibility_id The positioning method is used for parameters.
2.Uiautomatorviewer.bat (get the app's package and control properties)
The file is located under Your_andriod_sdk_path\tools.
This tool is primarily used to view the properties of a control, such as resource Id,class name.
The tool can also be used to view the apppackage of the app under test (desired capabilities).
3. Get the activity name
1, directly see the source code, recommended; 2. Anti-compilation
If there is no code, you can decompile the app.
There will be 2 tools, Dex2jar and Jd-gui, respectively.
Take the contactmanager.apk in the toolkit as an example and briefly describe the process of anti-compilation.
- 1, rename contactmanager.apk to Contactmanager.zip and unzip to get file Classes.dex;
- 2. Unzip the Dex2jar-0.0.9.15.zip and enter the folder from the command line; c:\appium\ APK anti-compilation \dex2jar-0.0.9.15
- 3, run the command d2j-dex2jar.bat c:\appium\apk Anti-compilation \com.meijialove.activity-1\classes.dex ,
- 4, decompression jd-gui-0.3.6.windows.zip get file Jd-gui.exe;
- 5, open Classes-dex2jar.jar with Jd-gui.exe;
3, check log, found in the Android Devices monitor log can see the name of the activity
From for notes (Wiz)
Appium Automation Testing (2)-Tools (monitor, Uiautomatorviewer)