Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.

This paper has participated inProject DigginTo win the creative gift package and challenge the creative incentive money.

preface

The most intuitive feature of APP for users is its beautiful and friendly UI interface. Before launching the APP, we not only conducted background data exchange tests such as basic function test, security test and performance test, but also conducted UI interface tests that have the greatest impact on users in user experience.

APP UI test mainly tests the user interface, window, dialog box layout, interface style, user-friendly and so on

APP UI test automation tools are also more, the mainstream has Appium, UIautomotor, Airtest and so on

The content related to APP UI test is summarized as follows:

In this installment, we will learn how to install the Android UI testing tool Appium. Let’s go~

1. Appium overview

Appium is an open source automated testing tool for not only Android mobile, but also IOS mobile, Windows desktop and mobile Web.

Appium is based on the WebDriver protocol and is cross-platform, allowing users to write tests on multiple platforms using the same APP.

We can check the updated features of Appium on the official website of Appium

Appium features:

  • Supports multiple platforms: IOS, Android, and Windows
  • Supports multiple languages, including Python and Java
  • There is no need to recompile the application
  • You don’t need to find the wheel repeatedly, you can share the API
  • Unit testing and cross-application testing are not supported

2. Working principle of Appium

Appium uses C/S mode

APPium consists of Testcase scripts, APPium Sever, and mobile devices

Let’s take a look at the working flow chart of APPium as follows:

  • Testcase is on the PC and communicates with the Appium Server through port 4723 by default
  • Appium is based on webDriver protocol, which is based on HTTP communication. The Appium Server and Android device are connected through TCP three-way handshake. The default port number is 4724
  • After the Appium Server establishes a connection with the device, the Server pushes the middleware bootstrap.jar to the device
  • After bootstrap.jar is pushed to the device, the device Socket is opened to listen for test instructions sent from port 4724
  • After receiving the test command, the device sends it to UiAutomator to execute the test command

3. Installation procedure of Appium

Appium can support multiple languages, but this installation is in Python

  • Script language: python3. x IDE: Install Pycharm

  • Installing the Java JDK (1.8)

    • JdK-8u211-Windows-x64.exe
    • Add an environment variable JAVA_HOME that specifies the JDK installation directory, for example, JAVA_HOME D :\tools\ Java \jdk1.8.0_211

  • Install Appium client (Appium Desktop download link)

  • Androidsdk.zip to download

    • Download from the official website of the androidsdk
    • Add an environment variable ANDROID_HOME to the SDK package decompression directory, such as D :\tools\ androidSDK

  • Start the Appium Server

Service startup:

  • The screen of the connected device is as follows

Equipment reference screen:

4. Frequently Asked Questions

  • “You must include a platformName capability”

    • Whether to select check parameters

    • Check other parameters

      After checking my parameters again, I found that platformVersion was wrong

  • Appium error An unknown server-side error occurred while processing the command. Original error: Could not find ‘adb.exe’ in PATH.

    • Check whether the environment variable ANDROID_HOME is configured properly

conclusion

This issue mainly introduces the working principle and installation steps of Appium. Appium communicates with the device based on WebDriver, and the device mainly executes script instructions through Ui Automator.

Appium itself is not limited by language and can be used across platforms. Therefore, for APP testing that supports multiple platforms, we only need to develop a set of test scripts to realize UI testing on multiple platforms, which greatly improves the efficiency of our testing

That’s the content of this episode. Please give us your thumbs up and comments. See you next time