Skip to content

II. Airtest Window

Airtest is a non-intrusive testing framework based on image recognition.

The Airtest testing framework provides a large number of testing APIs, allowing us to flexibly use them in test scripts to achieve testing functionality.

The commonly used APIs in Airtest include device connection/management, device operation, and assertion. AirtestIDE provides an Airtest recording assistant window that can quickly generate commonly used Airtest statements. This section mainly describes how to use the Airtest window to help us quickly generate Airtest scripts.

1.Recording Airtest Scripts with Auxiliary Buttons

In the AirtestIDE's Airtest window, there are three types of recording buttons:

Operation Type Assistive Type Assertion Type
Touch: touch Input text: text Assertion exists: assert_exists
Swipe: swipe Keyword operation: keyevent Assertion does not exist: assert_not_exists
Waiting for snapshot: wait Wait: sleep Assertion of equality: assert_equal
Snapshot exists: exists Assertion of inequality: assert_not_equal
Screenshot the current screen: snapshot

manual

2.Quick Snapshot Feature

The Airtest window also provides a quick snapshot function. Sometimes, we have written some snapshot scripts, but due to UI iteration or poor results, we need to retake the snapshot. In this case, we can use this quick snapshot function. We can also use this function to encapsulate custom logic for images, such as identifying a few images in a loop.

quick

3.Script Automatic Recording Freature

After clicking on the automatic recording button, use the mouse to operate on the device screen. The corresponding operation statement will be automatically inserted into the script in the editor.

4.Common Problems of Airtest Window

1) Recording touch script does not trigger a touch operation

Some versions of the IDE may not trigger the touch operation when recording touch or may execute a long touch instead of a single touch. This is because the recording process includes snapshotting, storing images, and releasing the mouse. If the IDE takes too long to handle these processes, particularly for high-resolution phones, there may be a problem where the screen does not respond to touch or responds incorrectly as a long touch. We will try our best to solve this problem in the subsequent versions.

2) Stuck when capturing screenshots of Windows apps

Some older versions of IDE require a double-click of the mouse to complete the snapshot of Windows apps after dragging it, which makes it look like being "stuck".