appium+python+win10 realizes automatic testing of Android phones

1. Install node.js 

2. Install and configure JDK

Details

3. Install and configure SDK

Details

4. Install appium

Official website: http://appium.io/  , the version of the article: v1.15.1 (different versions, some configurations are different)

5. Install appium-doctor to check whether the dependencies are complete

  • npm install -g cnpm --registry=https://registry.npm.taobao.org #Domestic mirror installation
  • cnpm install -g appium-doctor #Install appium-doctor by cnpm command
  • appium-doctor #View the environment configuration of appium
  • Note: The first 8 items must be installed, and Diagnostic for necessary dependencies completed, no fix needed is displayed here.

6. Start appium 

7. Keep appium started and run demo

from selenium import webdriver


desired_caps = {
      "platformName": "Android",
      "platformVersion": "6.0.1",
      "deviceName": "123b6e487cf3",
      "appPackage": "com.tencent.qqlivekid", # 小企鹅乐园 用于测试
      "appActivity": "com.tencent.qqlivekid.activity.WelcomeActivity",
      "unicodeKeyboard": True,
      "resetKeyboard": True
}
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)  # 启动app
driver.quit()

8. Parameter acquisition

版本号:cmd->adb shell getprop ro.build.version.release

Device name: cmd->adb devices

Get appPackage|appActivity: cmd->adb shell dumpsys window | findstr mCurrentFocus (when running the application, run this command)

9. Possible problems

You can check the detailed log if you encounter problems

You can use search not to retrieve whether there are missing dependencies

Need to install the apk on the tested end: search for the apk in the appium folder, copy it to the phone, and run it

The mobile phone needs to turn on the developer mode, Xiaomi clicks the version number several times, and needs to turn on the USB debugging

Guess you like

Origin blog.csdn.net/qq_41854291/article/details/105620274