This chapter introduces the key concepts of AirtestIDE and provides the very first steps how to work with AirtestIDE
mainly for users who do not have many experiences with mobile apps and game testing.

When connecting the device to AirtestIDE, make sure that Device Window is selected in Window menu.

There is the Mobile Phone Connection section on the right side of AirtestIDE GUI layout.

Once the mobile device is connected, click Refresh ADB button to display the connected phones in the devices list
table. If the status says Unauthorized, double check that the
USB debugging is enabled and the computer is
allowed to perform USB debugging on the device.

If the mobile device still does not appear in the devices list, try to click Restart ADB and then Refresh ADB
again. If the difficulties persist, perform following steps:

If the device is listed when executing command above but it does not appear in the IDE, feel free to
contact us and report the problem.

Click Connect button next to the device you want to connect, the content of the device screen will appear. If the
device is locked, it can be unlocked either directly using device buttons, or you can start to operate the device using
the IDE - e.g. click Power button below the screen to wake up the device and use the mouse to unlock the device.

Let’s have a look at the IDE windows layout. On the top, there is a menu bar and shortcut buttons for creating a new
project, saving project, run script and check the report output.

The upper left side contains the Poco Window that assists you to work with UI elements of the selected
interface and where you can see the selected UI interface in the tree structure form.

The bottom left side contains the Airtest Window that provides commonly used statements for assisting to
capture the recording of the Airtest scripts (based on image recognition techniques).

The central area contains the scripting section for developing own scripts in Python using Poco and
Airtest APIs. The log output section below displays the corresponding log content while executing the script.

On the right side, there is a mobile phone screen in real-time with support to use mouse events for remote control of
the device.

For easier understanding how AirtestIDE works, let’s assume the app you want to test is already installed on the
mobile device. For demonstration purposes and first test scenario, we use Google calculator app and we check if it
works properly by doing some actions in it.

We write the script directly inside the IDE under the line # start your script here (see the red section 1 in the
screenshot below).

For simulating the click on UI elements, we will Use the Poco framework which understands the Android UI elements
and is also responsible for simulating the inputs. To do so, change the mode of the Poco framework to Android as
shown in the following screenshot.

Note

As you can see, you can combine the Airtest APIs with Poco APIs without any restrictions

After doing that you will be prompted to answer the yellow message in the script area: “Poco mode has changed. Do you
want to insert poco init code at the current cursor position?”.

Answer Yes to add Poco init code to the line where your cursor is. At the same time, Poco framework determines
the UI hierarchy and draws it in a tree structure (see the yellow section 2 in the screenshot above)

All the input can be automatically captured, click on “Poco auto recording” to enable auto recording. Now, click on the
element you want to interact with on the phone screen in the IDE. You can see the currently selected button is being
highlighted and when you click on it, it will add code to your script.

At any point, you can click the “Poco auto recording” button again to stop capturing the actions and play the script
to see how it performs the actions in real life by pressing “Play” button.

Run the script using play button and wait for it to complete. Once it finishes, click on the Log button as shown
on screenshot below.

It will open the browser with the report what happened during the test. The test report includes one screenshot for
each action that was simulated including the information if the step was performed succesfully or not. You can also
see the assert result.

We can reach the same result with Airtest framework, however, the Airtest framework uses the different
approach. Airtest framework works on image recognition techniques, so we have to create the image templates first as
follows:

This is a calculator script with swipe, long press and several asserts actions.

# -*- encoding=utf8 -*-__author__="kristyna"__title__="little bit fun with calculator"__desc__="""having little bit fun with Google calculatorbasic functions"""# poco initfrompoco.drivers.android.uiautomationimportAndroidUiautomationPocopoco=AndroidUiautomationPoco(force_restart=False)# start Google calculatorstart_app("com.google.android.calculator")# make sure the initial state is clearifpoco("com.google.android.calculator:id/clr").exists():poco("com.google.android.calculator:id/clr").click()else:val=poco("com.google.android.calculator:id/formula").get_text()print("formula val")print(val)whilevalisnotNone:poco("com.google.android.calculator:id/del").long_click()val=poco("com.google.android.calculator:id/formula").get_text()# make side panel appear by clickingassert(notpoco("com.google.android.calculator:id/op_pct").exists())poco("com.google.android.calculator:id/arrow").click()assert(poco("com.google.android.calculator:id/op_pct").exists())# and then make the side panel disapear by swipingpoco("com.google.android.calculator:id/arrow").swipe([0.5,0.0])#Quick fix for the swipe issue#poco("com.google.android.calculator:id/digit_7").click()assert(notpoco("com.google.android.calculator:id/op_pct").exists())# test the delete key short presspoco("com.google.android.calculator:id/digit_7").click()poco("com.google.android.calculator:id/digit_3").click()assert_equal(poco("com.google.android.calculator:id/formula").get_text(),"73","Enter 73 operand")poco("com.google.android.calculator:id/del").click()poco("com.google.android.calculator:id/del").click()assert_equal(poco("com.google.android.calculator:id/formula").get_text(),None,"Delete operant short press")# simple multiplicationpoco("com.google.android.calculator:id/digit_5").click()poco("com.google.android.calculator:id/digit_6").click()poco("com.google.android.calculator:id/op_mul").click()poco("com.google.android.calculator:id/digit_4").click()poco("com.google.android.calculator:id/eq").click()val=poco("com.google.android.calculator:id/result").get_text()assert_equal(val,"224","simple multiplication")poco("com.google.android.calculator:id/clr").click()# simple additionpoco("com.google.android.calculator:id/digit_2").click()poco("com.google.android.calculator:id/op_add").click()poco("com.google.android.calculator:id/digit_2").click()poco("com.google.android.calculator:id/eq").click()val=poco("com.google.android.calculator:id/result").get_text()assert_equal(val,"4","simple addition")poco("com.google.android.calculator:id/clr").click()# chaining operationspoco("com.google.android.calculator:id/digit_2").click()poco("com.google.android.calculator:id/op_mul").click()poco("com.google.android.calculator:id/digit_9").click()poco("com.google.android.calculator:id/eq").click()poco("com.google.android.calculator:id/op_add").click()poco("com.google.android.calculator:id/digit_6").click()poco("com.google.android.calculator:id/eq").click()val=poco("com.google.android.calculator:id/result").get_text()assert_equal(val,"24","Chaining simple operations")poco("com.google.android.calculator:id/clr").click()poco("com.google.android.calculator:id/pad_advanced").click()poco("com.google.android.calculator:id/fun_sin").click()poco("com.google.android.calculator:id/digit_1").click()poco("com.google.android.calculator:id/digit_5").click()poco("com.google.android.calculator:id/eq").click()val=poco("com.google.android.calculator:id/result").get_text()assert(float(val)<0,"Sinus is not working")

Airtest script example

This is a calculator script to count 7 + 3 = 10 with the assertion to check the result. The script
contains the reference to screenshot templates created during the script recording and these
screenshots are part of .air project directory: