uiautomator
Rust async Android UI automation library with a Python uiautomator2-style API.
What This Crate Provides
- Device connection and mode routing (
Auto,AtxAgent,Direct) - Selector-based element lookup
- UiObject operations (click/input/clear/wait/info/text/bounds)
- Gestures, key events, screenshots, app lifecycle operations
- Structured errors with retry support for unstable device/RPC scenarios
Installation
Recommended first-use flow:
- Run
uiautomator-cli initonce for each target device. - Use this crate in application code.
[]
= "1.0.2"
= { = "1", = ["full"] }
Optional ATX-Agent installer support:
[]
= { = "1.0.2", = ["atx-agent-install"] }
Note:
- The
uiautomatorcrate package does not embed multi-archatx-agentbinaries to keep publish size within crates.io limits. - Recommended setup path is
uiautomator-cli init(or equivalent external provisioning) before usingAtxAgentmode. Device::connect(None)expects exactly one online ADB device. PassSome("<serial>")when multiple devices are connected.
Minimal Example
use ;
async
Error Handling Example
use Duration;
use ;
async
Modes
Auto(default): try ATX-Agent first, fallback to Direct.AtxAgent: use ATX-Agent transport (recommended for long-running/stable automation).Direct: direct JSON-RPC transport (fast setup, lower robustness).
Common APIs
Device:connect,info,find,click,swipe,press,screenshot,app_start,app_stopUiObject:exists,wait,wait_gone,click,long_click,set_text,clear_text,get_text,infoSelector: text/resource-id/class/description plus regex and hierarchy (child/sibling)
Testing
For full device regression, use the repository script from root:
powershell -NoProfile -ExecutionPolicy Bypass -File scripts/device-full-test.ps1 -Serial <serial>
Documentation
- Public requirements/design/tasks/release docs:
../docs/public/REQUIREMENTS.md../docs/public/DESIGN.md../docs/public/TASKS.md../docs/public/TESTING_RELEASE.md
- Error handling guide:
ERROR_HANDLING.md
Note: tests/** and examples/** stay in GitHub and are not included in the crates package by default.
License
MIT.