I’m participating in nuggets Creators Camp # 4, click here to learn more and learn together!

APP automated test running environment is relatively complex, a little attention to installation will fail. I’ve seen a lot of friends install Appium for a week and the environment is still not set up.

Setting up the environment itself is not a difficult task, but Appium does have a number of hidden holes that can take a long time to fix if you accidentally step on one of them.

Today, there is a detailed Appium installation tutorial, as long as you follow this and pay attention to each of the considerations I marked, you can easily install the Appium runtime environment.

Let’s take Android automated test environment as an example. APP automated test needs to be installed in the following environments:

  1. Appium services;
  2. Appium client;
  3. Java JDK
  4. Android SDK
  5. Mobile phone

1. Install Appium

The Appium service is installed in two forms: a GUI version and a command line version. The interface version has the same functionality as the command line version, except that it comes with an action interface that allows you to easily fill in the parameters for running Appium.

Go directly to the Appium GitHub download address and select the operating system version. If your operating system is Windows, choose the Windows installation package directly, if your operating system is MAC, choose the corresponding MAC installation package. Because the computer of nine handle is Windows system, so with Windows to demonstrate bar. The download speed of GitHub in China is relatively slow, and it may take several hours. If you do not have the condition of “quick access to GitHub”, you can directly send me a private message, and I will send you my local installation package.

After downloading the installation package, we directly click Install. There is a problem that needs to be paid attention to here. During the installation, choose to install only for myself instead of All Users, otherwise you may fail to run the APP due to permissions.

Once the installation is complete, we directly open the corresponding Appium icon and click On Start Services. At this point, the APP will listen on a local port. The default port number is 4723. You can change it to another port number that is not in use. When new instructions come in, the Appium service forwards them to the connected phone.

For the command line version of Appium, you need to install the Node.js runtime environment first, and directly download the LTS long-term support version from the Node.js official website. After the download is complete, specify the installation directory and remember the installation Path. Set the execution Path of Node.js to the environment variable Path on your computer.

After configuring the Path environment variable, install the Appium command-line tool using node.js’s package management tool NPM. NPM does not need to be installed separately, and can be used directly once node.js is installed.

npm install -g appium
Copy the code

After Appium is installed, you can start the service directly by typing Appium on the command line. You can use -p to change the port that the service listens to. You can also save the run log to a specified file path. You can directly use –help to obtain the description of each command line parameter.

C:\Users\jiubing> APpium -P 4444 [appium] Welcome to appium v1.22.0 [appium] non-default server args: [appium] port: 4444 [Appium] Appium REST HTTP Interface Listener started on 0.0.0.0:4444Copy the code

2. Install Appium

Appium client installation is relatively simple, it supports mainstream programming languages, nine handle is currently using Python language, so we directly install Python client, open the command line tool, use Python package management tool to complete the installation of Appium client.

pip install Appium-Python-Client
Copy the code

3. Install the Java JDK

Appium requires a Java 8 or higher development environment. We can download the latest version 8U202 from Oralce website. Due to network impact, you may not be able to download the oracle official website, so you can choose to download it through the domestic image. I often download it through the huawei image address, click Install after downloading, and set the installation path.

After the JDK is downloaded and installed, you also need to configure environment variables. Open the environment variables setting window, start menu -> right-click computer -> System Properties -> Advanced System Settings -> Advanced -> Environment Variables.

Click New, fill in the variable name JAVA_HOME, and the value is the JDK installation directory. In the pop-up box, fill in the variable value of the JDK installation root directory, that is, C:\Program Files\Java\jdk1.8.0_141) recorded above, as shown below:

Locate the Path variable in the system variable, click New, add configuration %JAVA_HOME%\bin, click OK, restart the computer, and let the environment variable take effect.

Open the Windows CMD window and enter the Java command to check whether the installation is correct. If the installation is ok, the normal version is displayed; otherwise, an error message is displayed.

C:\Users\jiubing> Java -version Java version "1.8.0_301" Java(TM) SE Runtime Environment (build 1.8.0_301-B09) Java HotSpot(TM) 64-Bit Server VM (Build 25.301-B09, Mixed mode)Copy the code

4. Install the Android SDK

At present, the operating environment of Android is mainly integrated in a software called Android Studio, which is a very large integrated development environment for Android software.

The app is very memory-hungry and, as an automated test, doesn’t use the vast majority of its features, so we’ll try the lighter ADT Bundle, which is billed as android’s new developer’s Bundle, which provides the necessary tools and environment to run Android.

Linux 64 bit, Linux 32 bit, MacOS X, Win32, Win64

Home Download address, are free of installation version, directly decompressed into the directory can be. If you feel troublesome, you can also send me a private message to get the latest version. I downloaded the upgraded system version tool.

Like the JDK, the Android environment needs to be configured with environment variables. After decompression, go to the corresponding adt-bundle-windows-x86_64-20140702\ SDK \platform-tools directory, which contains the related components and tools required for appium automation. Next we need to configure the platform-tools directory into the system environment variables for global use.

Go to the system environment variable Settings -> create ANDROID_HOME, the variable value is your SDK corresponding directory, such as my ADT package decompression is in disk D, then the SDK corresponding directory is: D:\adt-bundle-windows-x86_64-20140702\sdk

Add the SDK’s platform-tools directory and tools to the system variable Path: Click New in the Path and add the variables %ANDROID_HOME%\platform-tools and %ANDROID_HOME%\tools2. You can add any other variables you need. Set it up and restart the computer for the environment variables to take effect. Open a CMD window and type ADB version to check whether the installation is successful.

5. Cell phone connection

The phone can be an emulator, a real phone, or a cloud device.

If you are only using it for personal use and it is not convenient to use your real phone as a test machine, THEN I suggest you to install simulators. Currently, there are many mobile phone simulators in China, such as Thunder, Night God, Free and Easy, NetEase MUMu and Tencent Mobile Game Assistant.

Any company’s emulators can meet the needs of automated testing, and the Settings will vary slightly, but not significantly. For now, I’m going to use a lightning simulator to show you. (Official emulators are cleaner and start up faster if they can be tinkered with)

Download the latest emulator version directly from the Thunder website and install it like any other normal software. After installation, open the command line tool and type ADB Devices in the command line. If the emulator can be found normally, the following information will be displayed.

C:\Users\jiubing>adb devices
* daemon not running; starting now at tcp:5037
* daemon started successfully
List of devices attached
emulator-5554   device
Copy the code

6. Summary

At this point, the Appium running environment is set up, and matters needing attention are reminded again.

1, Appium service is divided into interface version and command line version, novice can directly use the interface version, faster, Appium download speed is very slow, own tools or do hand party, ask others can also.

2. Environment variables need to be set for both SDK and ADT Bundle. After setting, restart the computer.

3. Both emulators and real machines need to be recognized by adb commands.

I’m Jiubing, thanks for your patience to “read”, “like” and “+ follow”, we’ll see you next time.

(after)