Performing automation testing with Airtest

Airtest in an automation test framework with main focus on mobile games however it can be used for all native Android apps as well. Airtest automation test framework uses image recognition technologies and provides cross-platform APIs that allows among other to install applications, perform simulated input, make assertions, etc.

Learn more from project homepage or Fork Airtest on GitHub,

Airtest integration with AirtestIDE

Airtest assistant window is placed on the bottom left side of AirtestIDE GUI layout by default (as shown on screenshot below).


We can divide the buttons into three main groups - operations, assistant funtions and assertions:

Operations Auxiliary functions Assertions
touch text assert_exists
swipe keyevent assert_not_exists
wait server_call assert_equal
exist sleep assert_not_equal

These buttons can be easily filtered out using dropdown menu as follows:


Recording Airtest script in AirtestIDE

The instructions above can be combined with the Python code, combining Python scripting with predefined set of Airtest instructions, we can easily create a powerful fully automated test script.

There are two ways how to record the Airtest script - manually create screenshots or automatically capture all click actions on the screen and generate the screenshots automatically.

Following demonstrates how to record the script manually:

  1. select action you want to perform in Airtest window
  2. to select the object of interest, draw a rectangle on the target object on the screen device, the code will be automatically generated to your script
  3. repeat the steps for all objects you need to check

Sometimes, creating the screenshots manually is not very effective way, that’s why AirtestIDE also provides automatic recording features. In each step, wherever you click, the IDE will automatically capture the screenshots generated according to the current click area.

Automatic script recording can be turned on by click camera icon in Airtest window. To stop the automatic script recording, press the camera icon again.


Following demonstrates how to record the script automatically:


Running Airtest script and inspecting the report

AirtestIDE also provides the features to run/replay the script and inspect the test report which is generated once the script execution is finished. To do so, there are 3 buttons available to manage run script, stop script and inspect the log.


To run the script, perform following steps:

  1. click the start button (the most left button in the screenshot above)
  2. or press F5 key shortcut

To stop script, perform following steps:

  1. click the stop button (the middle button in the screenshot above)
  2. or press F10 key shortcut

To inspect the log, perform following steps:

  1. click the log button (the most right button in the screenshot above)
  2. or press Ctrl+L key combination

Image Editor Feature

AirtestIDE provides not only the ability to take the screenshots but also you can edit these captured screenshots using the Image Editor feature to adjust the image recognition parameters such as threshold, target position area and RGB channel to increase or adjust the image matching results.

To invoke the Image Editor dialog, double-click on the picture in script area. Click OK to accept your modification, or click Cancel to abandon it.


Following values can be adjusted for each captured screenshot:

threshold (float) - it sets the image matching threshold, the valid values are from interval [0.0, 1.0], the default value is 0.6

target_pos (int) - set the position to operate on image matching result, the valid values for position flag are from interval 1-9

RGB (bool) - set whether to use RGB channel or not when calculating the confidence of image matching result, the default value is False, i.e. use the gray image to calculate the threshold