🌈 Create new beautiful Compose Gradients with our new wesite ->
Function

captureToImage

Captures the underlying semantics node's surface into an ImageBitmap.

captureToImage

Source set: Android
@Deprecated(
    message = "Use captureToImage with explicit timeoutMillis instead.",
    level = DeprecationLevel.HIDDEN,
)
public fun SemanticsNodeInteraction.captureToImage(): ImageBitmap

Captures the underlying semantics node's surface into an ImageBitmap.

This can be used to capture nodes in a normal composable, as well as across multiple roots. Popups and Dialogs (if API >= 28) are specific cases of this, where they can be captured together with their anchor.

For example, selecting the root node (via onRoot()) when a popup or dialog is present will detect multiple roots. In this scenario, the resulting image is cropped to the combined bounding box of all nodes across the different roots. If a Dialog is present among the roots, the image is cropped to the window's visible display frame.

Throws: IllegalArgumentException

if an attempt is made to capture a bitmap of a dialog before API 28.

captureToImage

Source set: Android
public fun SemanticsNodeInteraction.captureToImage(timeoutMillis: Long = 2_000): ImageBitmap

Captures the underlying semantics node's surface into an ImageBitmap.

This can be used to capture nodes in a normal composable, as well as across multiple roots. Popups and Dialogs (if API >= 28) are specific cases of this, where they can be captured together with their anchor.

For example, selecting the root node (via onRoot()) when a popup or dialog is present will detect multiple roots. In this scenario, the resulting image is cropped to the combined bounding box of all nodes across the different roots. If a Dialog is present among the roots, the image is cropped to the window's visible display frame.

Parameters

timeoutMillis The maximum time (in ms) to wait for the drawing to complete. Default is 2000 ms.

Throws: IllegalArgumentException

if an attempt is made to capture a bitmap of a dialog before API 28.

Throws: ComposeTimeoutException

if drawing does not complete within timeoutMillis.