Skip to main content

Crate uiautomator2

Crate uiautomator2 

Source
Expand description

Async Rust client for uiautomator2 Android UI automation. Built on the adbutils crate.

The high-level Device API (d(text="OK").click()) lands in M2; M1 provides the transport (jsonrpc) and on-device server lifecycle (server::Server).

Re-exports§

pub use device::connect_usb;
pub use device::Device;
pub use errors::Error;
pub use errors::Result;
pub use input::EditorAction;
pub use proto::Direction;
pub use proto::DEFAULT_SERVER_PORT;
pub use selector::Selector;
pub use server::Server;
pub use session::Session;
pub use settings::Settings;
pub use uiobject::UiObject;
pub use watcher::Watcher;

Modules§

device
The high-level Device. Port of uiautomator2/__init__.py (_Device + _AppMixIn), delegating to three backends: JSON-RPC (on-device server), adb_device (the adbutils handle), and shell.
errors
Error types. Port of uiautomator2/exceptions.py.
input
IME text input via the AdbKeyboard. Port of uiautomator2/_input.py.
jsonrpc
JSON-RPC transport. Port of core.py _http_request / _jsonrpc_call.
proto
Constants and shared types. Port of uiautomator2/_proto.py (+ core.py:31).
selector
UiSelector builder + UiObject. Port of uiautomator2/_selector.py.
server
On-device server lifecycle. Port of core.py BasicUiautomatorServer + launch_uiautomator + MockAdbProcess.
session
App session. Port of Session in uiautomator2/__init__.py:910.
settings
Runtime settings. Port of uiautomator2/settings.py.
swipe
Directional swipe gesture. Port of uiautomator2/swipe.py (SwipeExt).
uiobject
UiObject — a lazily-resolved UI element query. Port of the UiObject class in uiautomator2/_selector.py. Nearly every RPC takes the serialized selector as its first parameter.
watcher
Background UI watchers. Port of uiautomator2/watcher.py.
xpath
XPath engine. Port of uiautomator2/xpath.py, pure-Rust.

Functions§

connect
Connect to a device (sole one, or by serial) and start the server. Mirrors u2.connect().
connect_server
Provision and start the raw server manager on dev (lower-level than connect; most users want connect/Device).