Skip to content

Snapshots and the event log

Screen snapshots with refs and the connection's event log, for tools that drive a device over several processes. Guide: Held connections and screen snapshots.

ScreenSnapshot

The visible screen as ref-addressed nodes (Device.screen_snapshot()). removed lists the previous snapshot's nodes that are gone; their refs no longer resolve. snapshot_id increases per attached device.

Methods:

Name Description
node

The node with ref (with or without the leading @), or None.

snapshot_id

snapshot_id: int

nodes

nodes: tuple[ScreenNode, ...]

removed

removed: tuple[ScreenNode, ...]

rotation

rotation: int

node

node(ref: str) -> ScreenNode | None

The node with ref (with or without the leading @), or None.

ScreenNode

One visible node of a ScreenSnapshot, in dump (pre-order) order.

ref (e<N>) stays the same across snapshots while the node is unchanged and is never reused for another node. selector is one the daemon found to match only this node in the dump (None when there is none); by_index marks one that ends in an index pick, which is right for this dump but fragile if the screen reorders. window_package is the package of the window the node is in. interactive: clickable, long-clickable, checkable, scrollable or editable.

ref

ref: str

depth

depth: int

window_package

window_package: str

class_name

class_name: str | None

resource_name

resource_name: str | None

text

text: str | None

content_description

content_description: str | None

hint

hint: str | None

bounds

bounds: Bounds

flags

flags: frozenset[NodeFlag]

password

password: bool

interactive

interactive: bool

selector

selector: Selector | None

by_index

by_index: bool

change

change: NodeChange

candidates

candidates: tuple[SelectorCandidate, ...]

Only from screen_snapshot(selector_candidates=True): every selector that matched only this node, best first (the first is selector).

showing_hint

showing_hint: bool

The field shows its hint rather than a value (text then holds the hint).

content_invalid

content_invalid: bool

The app marked the node's content invalid, e.g. a field that failed validation.

error

error: str | None

The error the app set on the node (TextView.setError), if any.

NodeChange

Bases: Enum

A ScreenNode against the previous snapshot of the same attached device. NONE: there was no previous snapshot.

NONE

NONE

ADDED

ADDED

UNCHANGED

UNCHANGED

REMOVED

REMOVED

NodeFlag

Bases: Enum

A boolean property of a node; ScreenNode.flags holds the ones that are true.

ENABLED

ENABLED

CHECKED

CHECKED

CHECKABLE

CHECKABLE

CLICKABLE

CLICKABLE

FOCUSED

FOCUSED

FOCUSABLE

FOCUSABLE

LONG_CLICKABLE

LONG_CLICKABLE

SCROLLABLE

SCROLLABLE

SELECTED

SELECTED

SelectorCandidate

One selector that matched only its ScreenNode in the dump, and how it does so.

selector

selector: Selector

kind

SelectorKind

Bases: Enum

How a SelectorCandidate singles out its node. PLAIN: one property (resource id, text, description or hint); COMBINED: two of the node's own properties; ANCESTOR: a property plus an ancestor it sits under; BY_INDEX: an index pick, right for this dump but fragile if the screen reorders. UNKNOWN: a kind this client does not know.

PLAIN

PLAIN

COMBINED

COMBINED

ANCESTOR

ANCESTOR

BY_INDEX

BY_INDEX

UNKNOWN

UNKNOWN

EventLog

TapConnection.event_log(): the kept events, oldest first, and how many older ones the server evicted (it keeps each connection's last 2000).

events

events: tuple[LoggedEvent, ...]

dropped

dropped: int

LoggedEvent

One device call from a connection's event log (TapConnection.event_log()).

The call and its outcome are the server API's own messages in proto3 JSON form with the .proto field names, so any language's protobuf library can parse them: command is a tap.v1.Command (for Execute) and app a tap.v1.AppCall (for an app lifecycle call); exactly one is set. error is the tap.v1.Error the driver returned and failure the tap.v1.Failure of a call that failed as an RPC; both are None when the call succeeded. at is when the call started (Unix seconds); duration is in seconds.

Methods:

Name Description
to_dict

A JSON-ready dict: the fields above with at as an ISO 8601 UTC timestamp and

seq

seq: int

at

at: float

duration

duration: float

serial

serial: str

command

command: dict | None

app

app: dict | None

error

error: dict | None

failure

failure: dict | None

ok

ok: bool

to_dict

to_dict() -> dict

A JSON-ready dict: the fields above with at as an ISO 8601 UTC timestamp and duration_ms; None fields are left out.