Artifacts¶
What device.screenshot(), dump_hierarchy(), info(), driver_log(), capture() and
stop_recording() return. Guide: Screenshots and artifacts.
Artifact
¶
Something the device produced that a test may keep: a Screenshot, a Hierarchy, a
DeviceInfo or a DriverLog. Every artifact is plain data with its serialized bytes
and media_type, so it can go to a file (save), a report, an upload or an assertion
without touching the device again.
Methods:
| Name | Description |
|---|---|
save |
Writes |
save
¶
save(path: str | PathLike[str]) -> Path
Writes bytes to path (parent directories are created) and returns it.
Screenshot
¶
ImageFormat
¶
Hierarchy
¶
DeviceInfo
¶
Bases: Artifact
Static facts about the device plus its current display, screen and focus state
(Device.info()). Serialized as JSON.
current_package
¶
current_package: str | None
The package owning the focused window, when there is one.
keyguard_secure
¶
keyguard_secure: bool
A PIN, pattern or password is set: Tap cannot dismiss this keyguard.
auto_rotate
¶
auto_rotate: bool
Auto-rotate is on: the sensor turns the display (off while a rotation is frozen).
animations_enabled
¶
animations_enabled: bool
Window, transition or animator animations run (any of the three scales is not 0).
wifi_enabled
¶
wifi_enabled: bool
Wi-Fi is switched on (also while airplane mode is on); says nothing about a connection.
mobile_data_enabled
¶
mobile_data_enabled: bool
Mobile data is switched on; False on a device without telephony.
system_locales
¶
system_locales: tuple[str, ...]
The device's languages, BCP-47 tags in preference order (Device.set_system_locales).
stay_awake
¶
stay_awake: bool
The screen stays on while the device is plugged in (Device.set_stay_awake).
high_contrast_text
¶
high_contrast_text: bool | None
High-contrast text is on; None when the driver cannot read it.
color_inversion
¶
color_inversion: bool | None
Colour inversion is on; None when the driver cannot read it.
DriverLog
¶
Recording
¶
Bases: Artifact
An opt-in device recording: MP4 video, Matroska video+audio, or Opus audio.
Device.stop_recording() returns these verified bytes; save them wherever a test
keeps its artifacts. A recording is never started implicitly on failure.
Capture
¶
The diagnostics of one device at one moment (Device.capture()): a Screenshot, the
Hierarchy, the DeviceInfo and the DriverLog. A part is None when it could not be
produced; failures says why, by part name.
Methods:
| Name | Description |
|---|---|
save_to |
Writes every produced part to |
artifacts
¶
artifacts: dict[str, Artifact]
The parts that were produced, by name: screenshot, hierarchy,
device-info, driver-log, in that order.
save_to
¶
save_to(directory: str | PathLike[str], prefix: str | None = None) -> list[Path]
Writes every produced part to directory as <prefix>.<name>.<extension> (for
example emulator-5554.screenshot.png; prefix defaults to the serial), creating
directory, and returns the written paths.