$ show AirtestProject/Airtest
Airtest is a cross-platform UI automation testing framework developed by NetEase, primarily targeting mobile games and apps. It provides a unified Python API and CLI for automating interactions on Android, iOS, Windows, and Linux devices. The core mechanism is image recognition using computer vision algorithms (template matching, keypoint matching with SIFT/KAZE/BRISK, etc.) to locate UI elements, combined with device-specific input simulation via ADB, minitouch, WebDriverAgent, and pywinauto. The framework supports complex gestures, multi-touch, screen recording, and HTML report generation with step logs and screenshots. Architecturally, Airtest is a library with a CLI entry point (`airtest run/report/info`). It uses a device abstraction layer with platform-specific implementations (Android, IOS, Windows, Linux) that share a common API through `airtest.core.api`. The image matching is handled by the `aircv` subpackage, which offers multiple matching strategies configurable via `CVSTRATEGY`. The Android module employs a proxy pattern for screen capture (Minicap, Javacap, ADB) and touch input (Minitouch, Maxtouch, ADB), allowing runtime switching. The framework also integrates with the Poco UI hierarchy inspection tool and supports cloud device testing. While the primary focus is application testing, the repository includes a small benchmark directory that compares the performance of various image matching algorithms, producing metrics like CPU, memory, and keypoint counts. This is a minor component and does not shift the overall classification away from application. The codebase is well-structured with clear separation of concerns, but shows signs of technical debt such as Python 2 compatibility shims, pinned outdated dependencies (opencv-contrib-python β€ 4.6.0.66, numpy < 2.0), and bundled precompiled binaries (minitouch, minicap, iproxy) that require periodic updates. The project is actively maintained with frequent commits and community engagement, but test coverage is limited due to reliance on real devices.
The LLM identified 4 files worth highlighting for reuse:
A comprehensive, well-structured ADB wrapper class that abstracts Android Debug Bridge commands. It provides methods for shell execution, device information retrieval, app management, port forwarding, screen capture, logcat streaming, and more. The class includes robust error handling (timeouts, subprocess failures, device offline detection), fallback strategies for parsing device properties, and automatic cleanup of forwarded ports. Its design is self-contained (only depends on standard library and `six`), making it reusable as a standalone ADB utility in other projects.
Implements the ScreenProxy class that acts as a faΓ§ade for multiple screen capture methods (Minicap, Javacap, ADB). It uses a registry of available methods and selects the most appropriate one based on device capabilities and configuration. The proxy handles initialization, orientation changes, and fallback between methods transparently. This pattern is a clean example of the Strategy pattern, allowing easy addition of new capture methods without modifying the caller code.
Defines a set of event classes (DownEvent, UpEvent, MoveEvent, SleepEvent) that represent low-level touch events. These can be composed into sequences to build complex multi-touch gestures (e.g., pinch, zoom, swipe). The classes are serializable to a text protocol used by minitouch/maxtouch. This component is isolated and can be reused in any project requiring programmatic touch event generation for Android or other platforms.
Provides a generic `retries` decorator that retries a function on failure with configurable wait times (exponential backoff). It also includes a `method-class` decorator for binding methods to classes. The retry logic is clean, parameterized, and not tied to any specific domain, making it a reusable utility for any Python project that needs fault-tolerant operations.