Appium environment configuration

Foreword

  Appium as a mobile terminal test automation tools are very popular in the industry, especially in the current context of the mobile Internet, many companies based on this framework to conduct automated testing. But appium environment configuration selenium is relatively complex, so many students daunting. This article describes appium + python windows-based platform to build environment. Build other platforms are similar.

      

Preparing the Environment

  • jdk1.8
  • node
  • appium
  • android-sdk
  • python
  • Appium-python-client 

 

First, install jdk, configure the environment variables

1. Download: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2. The installation process is not to say, after configuring the environment variables, check for success:

 

Second, the installation Appium

method one:

1. Install node.js, Download: http://nodejs.cn/download/

2. Check whether the installation successfully

3. Then the installation using the command: npm install -g appium  

Method Two:

1. Download: http://appium.io/

2. After installing the configuration environment variables: the installation Appium home directory C: \ Program Files \ Appium added to the system variable Path

3. Check the next, can open Appium on behalf of success:

 

Third, the installation android-sdk

1. Download: https://www.androiddevtools.cn/   (can also be mounted directly android studio development tool that integrates the android-sdk)

2. After extracting run SDK Manager.exe

3. Download the build-tool tool, will be used later aapt command.

 

 4. Configuration Environment variables:

 1) New system variable names ANDROID_HOME, variable value: D: \ android-sdk-windows (android-sdk home directory)

 2) Add the system variable Path aapt adb and variable values.

      adb variable value: D: \ android-sdk-windows \ platform-tools

      aapt variable value: D: \ android-sdk-windows \ build-tools \ 29.0.2

5. Check the environment variable configuration is successful:

 

 

Fourth, the installation appium-doctor

1. The latest version of Appium without appium-doctor, you need to download their own

2.cmd installation command: npm install -g appium-doctor (-g parameter setting environment variables appium-doctor)

3. Run appium-doctor checking appium required to run the dependency and environmental variables (of course, more confident students can skip this step unnecessary steps Ha!)

 

Fifth, install python

1. Download: https://www.python.org/

2. The installation process is not to say, Fool installation.

 

6, installation Appium-Python-Client 

 Use python library management tools pip, cmd input: pip3 install Appium-Python-Client 

 

 

Examples of use

First, open the simulator

1. Run the simulator can use the built-in android, I used here is Genymotion. Why do I use Genymotion, of course, is to run faster, ha ha! As shown below

 

Second, run Appium

 1.cmd run command appium. (There is a problem, manually enable appium, running the script will be reported when the Original error: Could not find 'adb.exe' in PATH, but adb environment variable is successfully configured temporarily unclear why.)

2. Open the interface, click "Start Server", Appium start listening.

 

Three, aapt command to get the apk package name

1.aapt command can get more information packet, specific usage: aapt dump badging xxx / xxx / yy.apk then find PackageName

 2. Then find the above launcherActivity

 

 

Four, adb acquisition device name

1.cmd enter the command: adb devices

 

Fifth, run a script

 Run the following test code, the parameters deviceName, appPackage, appActivity above values ​​have been acquired before. Home app was transferred from representatives of Success:

from appium import webdriver

desired_caps = {

                'platformName': 'Android',

                'deviceName': '192.168.41.101:5555',

                'platformVersion': '9.0',

                # apk包名

                'appPackage': 'com.gem.tastyfood',

                # apk的launcherActivity

                'appActivity': 'com.gem.tastyfood.LaunchActivity'

                }

# Remote 地址在 Appuim 里找
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)  

 

Guess you like

Origin www.cnblogs.com/shenh/p/11758917.html