Skip to content

Automated test for WeChat applets and mini games

In addition to supporting native applications, games, and the Web, the Airtest Project automated testing solution also supports the newly launched WeChat applets and Mini Game Platform.Let's take a look at how to use the Airtest Project for automated testing of applets and games:


For WeChat applets, we can directly use Poco on the native platform for control recognition.For the current kernel information of WeChat applets, please refer to Official Documents.We use the latest version (V7.0.4) of WeChat test, so you can directly use Android or iOS poco mode to identify the control of the applet of the corresponding platform.If it is not available, it may be due to the Webview kernel settings of some Android devices. Please refer to the Document for modification.

Let's take a look at the effect on the Android and iOS platforms:

Android Applets

Connect an Android phone and open the WeChat applet. Take the Starbucks applet as an example. Select the Android mode in the Airtest IDE to identify the controls on the page:


iOS Applets

Connect an iOS phone and open the WeChat applet. Take the Starbucks applet as an example. Select the iOS mode in the Airtest IDE to identify the controls on the page:


The following sample code can implement operations such as clicking the corresponding carousel on iOS:

from airtest.core.api import *


from poco.drivers.ios import iosPoco
poco = iosPoco()

while not poco("感恩有你").exists():
    poco.scroll(direction='vertical', percent=0.3, duration=1.0)


Mini games

Airtest can use image recognition for automated testing of small games. In addition, Poco UI control retrieval also supports small games developed using Egret Engine. Accessing Poco requires accessing poco-sdk in the source code. The specific access guidelines are as follows:

Environment configuration

  • First download poco-sdk
  • Then modify the modules property in egretProperties.json and add the corresponding fields in the red box, where the name attribute must be poco
  • The path can be a relative path or an absolute path. For details, refer to the description of the modules field in the Egret Engine Documentation.


  • Then use the shortcut key ctrl+` to call the terminal and execute the command egret build -e in the terminal

  • Create a new object of type PocoManager in the rungame function of the entry file main.ts, and pass this.stage

  • Run the code and start the game
  • Finally, enter python -m ws://*:5003 tcp://*: 15004 in the terminal to open the proxy server broker
  • The websocket port defaults to 5003. If you need to change it, you can pass in the port parameters when creating a new pocomanager.

Connect with AirtestIDE

Connect a mobile browser

AirtestIDE supports Android and iOS phone connections. You can open the Egret page (or WeChat applet / game) on your phone and then connect through AirtestIDE. Both Windows and MacOS versions of the IDE can be used. The basic principle of the connection is:


Specific steps are as follows:

  1. Connect the Android phone via usb and confirm that there is no problem with the connection of adb devices. Execute the following command on the computer to map the 5003 port of the mobile phone to the 5003 port of the computer
adb reverse tcp:5003 tcp:5003
  1. Start the broker on your computer:
 python -m "ws://*:5003" "tcp://*:15004"

After starting the broker, visit Egret's page on the phone (you need to use the full screen mode to ensure accurate coordinates). During the visit, the broker will print the log of the mobile connection, as follows:

~ python -m "ws://*:5003" "tcp://*:15004"
server listens on ("", 5003) transport websocket
server listens on ("", 15004) transport socket
StdBroker on.
server on accept. < object at 0x1100620d0>
  1. Open AirtestIDE and connect your phone. Then select Std-broker mode of poco, and you can see the UI hierarchy. At the same time, the broker will print the connection log:
server on accept. < object at 0x10d03d2d0>
accept from: ('', 56872)
received_message from ('', 56323) {"id":"2a0ce828-132e-4d15-a645-55493d7eaf4b","jsonrpc":"2.0","result":{"children"

The AirtestIDE interface is as follows:


You can write scripts and run scripts in AirtestIDE, and you can also view reports.