Brief introduction
Reference: https://testerhome.com/topics/12391
Airtestide is a cross-platform UI Automation Test editor for games and apps.
- Automate your test process with automated script recording, one-click Playback, and report viewing
- Supports image recognition-based airtest framework for all Android and Windows games
- Support for Poco framework based on UI control search for Unity3d,cocos2d and Android apps
- Ability to run on windows and MacOS
- NetEase internal has been successfully applied to dozens of projects, the use of mobile phone cluster for large-scale automated testing
Visit the official website to view more features via video.
With this tutorial, you'll learn how to get started with automated testing (or write a script to play the game automatically). Believe me, this process will be very enjoyable ~
Installation
Currently airtestide provides Windows and Mac two versions of the client, please download from the official website, unzip is available.
Connecting devices
Airtestide currently supports testing apps on Android and Windows, and iOS support is under development.
Connect your Android Phone
Connect your PC and Android phone via ADB to start debugging Android apps. ADB is Google's official Android debugging tool. Airtestide relies on ADB to communicate with Android devices.
To open Airtestide, follow these steps to connect:
- Turn on
设置-开发者选项-USB调试 The phone switch and refer to the official Android documentation
- Click the button in the Airtestide device panel
Refresh ADB to view the devices on the connection
- If the device is not displayed, try it,
Restart ADB if not, refer to FAQ
- Click on the corresponding Device
Connect button to initialize
Once your phone is connected, you can see the image of your phone's screen in the Airtestide and do it in real time.
If your phone connection fails, please submit your phone model and airtestide background error to Github issues. The developer will fix it as soon as possible. because of the serious problem of fragmentation of Android phones, we appreciate your feedback to help the project do better.
Connect Windows window
For tests of Windows desktop programs, we usually test a window. Airtestide can embed the test window for easy script recording and debugging.
- Click the button in the Airtestide device panel
Windows-框选游戏窗口
- Moving the mouse over the window of the program under test will show the window with the Green border box
- Click the left button to embed the corresponding window into the Airtestide
You can also use an alternate embedding method if the program's window is not correctly found in the above method .
Connect to your iOS phone
Coming soon:)
Recording Automation scripts
Now we can start recording automated test scripts.
Analog input
Start with the most commonly used analog clicks.
Based on image recognition
Click the button on the Airtest Auxiliary window, 录制 and then as you manipulate the phone on the device window, the code is automatically generated in the Code window.
Check it out now and click on 运行 the button to run your first automated script!
If you feel that the auto-recorded icon is not accurate enough, you can also click the button on the Airtest Auxiliary window touch and select the exact icon on the device window, or you can generate the touch statement automatically.
A similar analog input operation also has a swipe: click on the swipe button, select the precise icon on the device window as the starting point, and then click the sliding end position, which will automatically generate a swipe statement.
Other APIs for analog input include:
- Text: Type input
- KeyEvent: Key input, including (Home/back/menu, etc.)
- Sleep: Wait
- Snapshot: Screen Cutting
Based on UI controls
If you find that image recognition is not accurate enough, you can use a UI-based control search method for automated testing.
Currently Airtestide directly supports Unity3d, cocos2d two game engines and Android native apps. since the game engine renders directly using graphics interfaces such as OpenGL, instead of using the Android source UI system, we need to communicate with the runtime of the game to get the entire UI structure. Unity3d and Cocos2d-js we offer very handy SDK access to the point here .
Other game engines and UI systems we provide the SDK to expand itself.
In fact in the NetEase game inside we are in this way to support the messiah/neox/dream and other self-research engine.
- Unity3d and cocos2d games: Access SDK
- Android Source app: Start straight!
- Other game engines and UI systems: Extension SDK
We can start when the access is complete. The phone launches the game, switching modes to the corresponding engine type in the Poco auxiliary window to see the entire UI structure.
Click the Record button, and as you do, the POCO statements are generated automatically.
Similarly, you can view UI controls more precisely through the UI tree structure, double-click to automatically generate POCO statements, or choose a better way to do it yourself. Better attribute selection often enhances the robustness and readability of the entire automation script, which is a learning thing .
Remember to run the test after you have finished recording the script.
Since the UI structure of the Android source app app can be Accessibility obtained, we'll start using it directly. switch the mode of the Poco auxiliary window to Android can see the entire UI tree structure.
In fact, the above two approaches are based on two frames, respectively:
- Airtest framework based on image recognition for all Android and Windows games
- A Poco framework based on UI control search for unity3d,cocos2d and Android apps
Both frameworks are developed by our team, and in actual project use experience, we find that the combination of the two will get the best results.
Using Python syntax
The code that is recorded and run throughout the Airtestide is language-based Python2.7 . The python syntax is simple and powerful, and there are many third libraries and tools.
For beginners, Python is easy to get started with and learns the basic syntax to write out the logical statements required in an automated script.
touch("开卡包.png")if exists("奖励面板.png"):for i in range(5): Poco("奖励-%s" % i).click()
For the veteran, you can use a variety of third-party libraries in airtestide to make your Automation scripts more powerful and add Pythonpath.
In addition to the statements provided in the Auxiliary window, more API documentation is available to view the Airtest and Poco repositories.
Here, we have a variety of analog input methods, with logic control statements to move the phone up. There is also an important step in automated testing: Results validation, so let's look at how to declare assertions.
Validating the UI interface
Recording method is similar to analog input
- Assert_exists: Assert that the picture exists
- Assert_not_exists: Assertion picture does not exist
Verifying values
Get property values through Poco, handwritten code asserts
- Assert_equal: assertion Equality
- Assert_not_equal: Assertion Unequal
For example
# ... 模拟输入并获得20分之后value = Poco("分数按钮").attr("num")assert_equal(value, 20, "获到20分")
View Test Reports
When the script finishes running, clicking the 查看报告 button (shortcut ctrl+l) will open the Results report page using the default browser. The report will show the contents of each step and the results of the actual execution, making it easy to see if the steps are successful.
Command line interface
Now you've learned to automate tests. Next, you can use the command-line interface to combine automated testing with continuous integration. What is continuous integration?
When you run the script in Airtestide, the Run command is printed in the log window.
You can use that command at the command line to start a test script without opening the IDE, for example:
"D:\AirtestIDE\AirtestIDE" runner "D:\AirtestIDE_2018-01-24_83\untitled.air" --device Android://127.0.0.1:5037/F8UDU16409004135 --log "C:\Users\gzliuxin\AppData\Local\Temp\AirtestIDE\scripts\cdfc40e8c297b6ad88e09de64d8bafa3"
With Airtestide you can easily record test scripts and save them as .air scripts. Please note that a .air don't include too much content in the script, organize your script with good script naming and directory structure, and overwrite all test points.
You can also run tests against different devices on different computers, and you'll need to run the. Air script using the command line. for multi-platform released products, flexible use of cross-platform APIs and command lines, as well as the same set of test scripts to run on Android and Windows for testing.
Within NetEase games, our large-scale games usually have hundreds of test scripts that cover commonly used gameplay tests. each week, these hundreds of scripts run on 200 phones for compatibility testing. Demo
More extended Features
Editor settings
Introducing a third-party Python library
Custom Launcher
Build a cloud test platform
Combined with Google Firebase
Airtestide Game automation (Unity3d across Windows, Mac, IOS, Android)