Top Related Projects
UI Recorder is a multi-platform UI test recorder.
Windows Application Driver
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Fast, easy and reliable testing for anything that runs in a browser.
A browser automation framework and ecosystem.
Sikuli's official repository on github. Ask questions or report bugs at http://launchpad.net/sikuli.
Quick Overview
Airtest is an open-source cross-platform automated testing framework for games and apps. It provides a set of tools and APIs for writing test scripts using Python, allowing developers and testers to automate UI interactions, image recognition, and device control across multiple platforms including Android, iOS, and Windows.
Pros
- Cross-platform support for Android, iOS, and Windows
- Intuitive API with image recognition capabilities
- Integration with popular IDEs like PyCharm
- Extensive documentation and active community support
Cons
- Steep learning curve for users new to Python or automated testing
- Image recognition can be sensitive to screen resolution and device differences
- Limited support for complex gestures and multi-touch interactions
- Performance may be slower compared to native testing frameworks
Code Examples
- Basic UI interaction:
from airtest.core.api import *
# Initialize the device
init_device("Android")
# Click on an image
touch(Template("button.png"))
# Input text
text("Hello, Airtest!")
# Wait for an element to appear
wait(Template("loading.png"), timeout=10)
- Assertion and verification:
from airtest.core.api import *
# Check if an image exists on screen
assert_exists(Template("logo.png"), "Logo is visible")
# Verify text content
text_content = ocr_text()
assert "Welcome" in text_content, "Welcome message not found"
- Multi-device testing:
from airtest.core.api import *
from poco.drivers.android.uiautomation import AndroidUiautomationPoco
# Connect to multiple devices
dev1 = connect_device("Android:///device1")
dev2 = connect_device("Android:///device2")
# Switch between devices
set_current(dev1)
touch(Template("button1.png"))
set_current(dev2)
touch(Template("button2.png"))
Getting Started
-
Install Airtest:
pip install airtest
-
Create a new Python file and import Airtest:
from airtest.core.api import *
-
Initialize the device and start writing your test script:
# Connect to an Android device init_device("Android") # Perform actions touch(Template("start_button.png")) swipe(Template("menu.png"), vector=[0.5, 0]) # Add assertions assert_exists(Template("result.png"), "Test passed")
-
Run the script using the Airtest CLI or IDE plugin.
Competitor Comparisons
UI Recorder is a multi-platform UI test recorder.
Pros of uirecorder
- Supports multiple browsers and platforms, including mobile devices
- Provides a user-friendly interface for recording and editing test cases
- Generates test scripts in multiple languages (JavaScript, Java, Python)
Cons of uirecorder
- Limited image recognition capabilities compared to Airtest
- Less extensive documentation and community support
- Fewer built-in tools for game testing and automation
Code Comparison
uirecorder (JavaScript):
describe('Test Case', function(){
it('should open website', function(){
browser.url('https://example.com');
expect(browser.getTitle()).to.equal('Example Domain');
});
});
Airtest (Python):
from airtest.core.api import *
auto_setup(__file__)
touch(Template("button.png"))
assert_exists(Template("result.png"))
Key Differences
- uirecorder focuses on web and mobile app testing, while Airtest specializes in game and app testing
- Airtest uses image recognition extensively, whereas uirecorder relies more on DOM elements
- uirecorder generates human-readable test scripts, while Airtest uses a more visual approach with image-based assertions
Both tools have their strengths, with uirecorder being more suitable for traditional web testing and Airtest excelling in game and mobile app testing scenarios.
Windows Application Driver
Pros of WinAppDriver
- Specifically designed for Windows applications, providing native support for Windows UI Automation
- Supports a wide range of Windows application types, including UWP, WPF, and Win32
- Integrates well with existing Selenium and Appium test frameworks
Cons of WinAppDriver
- Limited to Windows platform, lacking cross-platform support
- Requires more setup and configuration compared to Airtest
- Less intuitive for beginners, with a steeper learning curve
Code Comparison
WinAppDriver:
var desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.SetCapability("app", "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App");
var session = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredCapabilities);
var button = session.FindElementByName("One");
button.Click();
Airtest:
from airtest.core.api import *
auto_setup(__file__)
touch(Template("button.png"))
text("Hello, Airtest!")
snapshot("result.png")
The code comparison shows that WinAppDriver uses a more traditional Selenium-like approach, while Airtest offers a simpler, image-based automation syntax. WinAppDriver provides more precise control over Windows elements, whereas Airtest focuses on cross-platform compatibility and ease of use for GUI automation.
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Pros of Appium
- Supports a wider range of platforms, including iOS, Android, and Windows
- Larger community and ecosystem, with more resources and third-party integrations
- Uses standard WebDriver protocol, making it easier for those familiar with Selenium
Cons of Appium
- Steeper learning curve, especially for those new to mobile testing
- Can be slower in test execution compared to Airtest
- More complex setup and configuration process
Code Comparison
Appium (Python):
from appium import webdriver
caps = {}
caps["platformName"] = "Android"
caps["deviceName"] = "emulator-5554"
caps["appPackage"] = "com.example.app"
caps["appActivity"] = ".MainActivity"
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
Airtest (Python):
from airtest.core.api import *
auto_setup(__file__)
connect_device("Android:///")
start_app("com.example.app")
touch(Template("button.png"))
Airtest offers a more straightforward syntax for common mobile testing tasks, while Appium provides a more standardized approach using WebDriver. Airtest's image recognition capabilities are more prominent in its basic usage, whereas Appium relies more on element locators.
Fast, easy and reliable testing for anything that runs in a browser.
Pros of Cypress
- More robust and mature ecosystem with extensive documentation and community support
- Built-in debugging tools and real-time reloading for faster development
- Supports modern web technologies and frameworks out of the box
Cons of Cypress
- Limited to testing web applications only, unlike Airtest's cross-platform capabilities
- Lacks support for multi-tab testing and certain browser actions
- Steeper learning curve for beginners compared to Airtest's simpler approach
Code Comparison
Cypress example:
describe('Login Test', () => {
it('should log in successfully', () => {
cy.visit('/login')
cy.get('#username').type('testuser')
cy.get('#password').type('password123')
cy.get('#login-button').click()
cy.url().should('include', '/dashboard')
})
})
Airtest example:
from airtest.core.api import *
auto_setup(__file__)
touch(Template("login_button.png"))
text("testuser", target=Template("username_field.png"))
text("password123", target=Template("password_field.png"))
touch(Template("submit_button.png"))
assert_exists(Template("dashboard_icon.png"))
Both examples demonstrate a simple login test, but Cypress uses a more code-based approach, while Airtest relies on image recognition for UI interactions.
A browser automation framework and ecosystem.
Pros of Selenium
- Widely adopted and supported across multiple programming languages
- Extensive documentation and large community for support
- Robust support for various browsers and operating systems
Cons of Selenium
- Steeper learning curve, especially for non-programmers
- Can be slower for certain types of automation tasks
- Requires more setup and configuration compared to Airtest
Code Comparison
Selenium (Python):
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.example.com")
element = driver.find_element_by_id("search")
element.send_keys("test")
Airtest (Python):
from airtest.core.api import *
auto_setup(__file__)
touch(Template("search_button.png"))
text("test")
Selenium focuses on web automation using DOM elements, while Airtest uses image recognition for cross-platform GUI automation. Selenium requires more code for setup and element identification, whereas Airtest relies on visual cues and provides a more concise syntax for common actions.
Selenium is better suited for complex web automation tasks and integration with continuous integration systems. Airtest excels in cross-platform GUI testing, especially for games and mobile applications, with its image recognition capabilities and simplified scripting approach.
Sikuli's official repository on github. Ask questions or report bugs at http://launchpad.net/sikuli.
Pros of Sikuli
- More mature project with a longer history and established community
- Supports multiple programming languages (Python, Ruby, JavaScript)
- Extensive documentation and tutorials available
Cons of Sikuli
- Less frequent updates and maintenance
- Limited mobile device support compared to Airtest
- Steeper learning curve for beginners
Code Comparison
Sikuli (Python):
click("button.png")
type("Hello, World!")
wait("result.png", 10)
Airtest (Python):
touch(Template("button.png"))
text("Hello, World!")
wait(Template("result.png"), timeout=10)
Both Sikuli and Airtest use image recognition for GUI automation, but Airtest provides a more streamlined syntax and better support for mobile testing. Sikuli offers more flexibility with language choices, while Airtest focuses on Python and provides a more integrated environment for both desktop and mobile testing.
Sikuli's strength lies in its established ecosystem and cross-language support, making it suitable for diverse projects. Airtest, on the other hand, excels in mobile testing and offers a more user-friendly approach for newcomers to GUI automation.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Airtest ·
Cross-Platform UI Automation Framework for Games and Apps
跨平å°çUIèªå¨åæ¡æ¶ï¼éç¨äºæ¸¸æåApp ï¼ä¸æçç¹è¿éï¼
Features
-
Write Once, Run Anywhere: Airtest provides cross-platform APIs, including app installation, simulated input, assertion and so forth. Airtest uses image recognition technology to locate UI elements so that you can automate games and apps without injecting any code.
-
Fully Scalable: Airtest cases can be easily run on large device farms, using commandline or python API. HTML reports with detailed info and screen recording allow you to quickly locate failure points. NetEase builds Airlab on top of the Airtest Project.
-
AirtestIDE: AirtestIDE is an out of the box GUI tool that helps to create and run cases in a user-friendly way. AirtestIDE supports a complete automation workflow:
create -> run -> report
. -
Poco: Poco adds the ability to directly access object(UI widget) hierarchy across the major platforms and game engines. It allows writing instructions in Python, to achieve more advanced automation.
Get started from airtest homepage
Supported Platforms
Installation
Use pip
to install the Airtest python library.
pip install -U airtest
On MacOS/Linux platform, you need to grant adb execute permission.
# for mac
cd {your_python_path}/site-packages/airtest/core/android/static/adb/mac
# for linux
# cd {your_python_path}/site-packages/airtest/core/android/static/adb/linux
chmod +x adb
Download AirtestIDE from our homepage if you need to use the GUI tool.
Documentation
You can find the complete Airtest documentation on readthedocs.
Examples
Airtest aims at providing platform-independent API so that you can write automated cases once and run it on multiple devices and platforms.
- Using connect_device API you can connect to any android/iOS device or windows application.
- Then perform simulated input to automate your game or app.
- DO NOT forget to make assertions of the expected result.
from airtest.core.api import *
# connect an android phone with adb
init_device("Android")
# or use connect_device api
# connect_device("Android:///")
install("path/to/your/apk")
start_app("package_name_of_your_apk")
touch(Template("image_of_a_button.png"))
swipe(Template("slide_start.png"), Template("slide_end.png"))
assert_exists(Template("success.png"))
keyevent("BACK")
home()
uninstall("package_name_of_your_apk")
For more detailed info, please refer to Airtest Python API reference or take a look at API code
Running .air
cases from CLI
Using AirtestIDE, you can easily create automated cases as .air
directories.
Airtest CLI provides the possibility to execute cases on different host machines and target device platforms without using AirtestIDE itself.
# run cases targeting on Android phone connected to your host machine via ADB
airtest run "path to your .air dir" --device Android:///
# run cases targeting on Windows application whose title matches Unity.*
airtest run "path to your .air dir" --device "Windows:///?title_re=Unity.*"
# generate HTML report after running cases
airtest report "path to your .air dir"
# or use as a python module
python -m airtest run "path to your .air dir" --device Android:///
Try running provided example case: airtest/playground/test_blackjack.air
and see Usage of CLI. Here is a multi-device runner sample.
Contribution
Pull requests are very welcome.
Thanks
Thanks for all these great works that make this project better.
Top Related Projects
UI Recorder is a multi-platform UI test recorder.
Windows Application Driver
Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
Fast, easy and reliable testing for anything that runs in a browser.
A browser automation framework and ecosystem.
Sikuli's official repository on github. Ask questions or report bugs at http://launchpad.net/sikuli.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot