test environment
- Win 10 64bit
- Python
- pycharm
- appium
- Andriod
- Test App:
testing scenarios
Install the app automatically and
start the app
Test steps
- Get the packageName and Activity of the app to be tested
- Configure Capability
- Connect the device
- Edit the script and run
- View Results
Check items before operation
- 1. Check if the device is connected
- 2. Check whether the Appium server is started
- 3. Check whether the Capability configuration information is correct
Script (edited in pycharm compiler)
from appium import webdriver
desired_caps = {
}
desired_caps['platformName'] = 'Android'
desired_caps['devicesName'] = '红米手机' # 手机名称可以在手机设备信息上查询到
desired_caps['platformVersion'] = '6.0'
desired_caps['udid'] = 'AAYDAUV87S5H8T95' # Udid 可以使用adb devices 查看
desired_caps['app'] = r'C:\Users\Administrator\Desktop\2c5a28d6-7f00-469f-b985-a5b934803a27.apk'
desired_caps['appPackage'] = 'com.kyscgenuiphone'
desired_caps['appActivity'] = 'com.newtzt.activity.common.activity.tztHeadPageActivity'
appdriver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps) # 第一个参数是appium Server的地址
Precautions
Start Appium for the first time
When Appium is started for the first time, two guardian apps will be installed on the device. Appium Settings and Unlock Some device systems have permission issues (such as Samsung S6 edge+) that require the user to manually confirm the installation. Otherwise, if the guardian app is not installed, the script will fail and the installation is complete. Do not uninstall these two apps at will.
- Unlock: Used to unlock the phone pop-up prompt
- Appium Setting: appium 守护 app
Module import
The webdriber module in from appium import webdriver is different from the webdriver module in selenium!
Webdriver module source code path:
{python installation path}}\Lib\site-packages\appium\webdriver