{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SemanticsNodeInteractionsProvider

public interface SemanticsNodeInteractionsProvider

Known direct subclasses
ComposeTestRule

A TestRule that allows you to test and control composables and applications using Compose.

ComposeUiTest

A test environment that allows you to test and control composables, either in isolation or in applications.

Known indirect subclasses
AndroidComposeTestRule
AndroidComposeUiTest

Variant of ComposeUiTest for when you want to have access to the current activity of type A.

ComposeContentTestRule

A ComposeTestRule that allows you to set content without the necessity to provide a host for the content.


Provides the main entry point into testing.

Typically implemented by a test rule.

Summary

Public methods

abstract @NonNull SemanticsNodeInteractionCollection
onAllNodes(@NonNull SemanticsMatcher matcher, boolean useUnmergedTree)

Finds all semantics nodes that match the given condition.

abstract @NonNull SemanticsNodeInteraction
onNode(@NonNull SemanticsMatcher matcher, boolean useUnmergedTree)

Finds a semantics node that matches the given condition.

Extension functions

default final @NonNull SemanticsNodeInteractionCollection
FindersKt.onAllNodesWithContentDescription(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String label,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds all semantics nodes with the given label as ContentDescription.

default final @NonNull SemanticsNodeInteractionCollection
FindersKt.onAllNodesWithTag(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String testTag,
    boolean useUnmergedTree
)

Finds all semantics nodes identified by the given tag.

default final @NonNull SemanticsNodeInteractionCollection
FindersKt.onAllNodesWithText(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String text,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds all semantics nodes with the given text.

default final @NonNull SemanticsNodeInteraction
FindersKt.onNodeWithContentDescription(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String label,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds a semantics node with the given contentDescription.

default final @NonNull SemanticsNodeInteraction
FindersKt.onNodeWithTag(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String testTag,
    boolean useUnmergedTree
)

Finds a semantics node identified by the given tag.

default final @NonNull SemanticsNodeInteraction
FindersKt.onNodeWithText(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String text,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds a semantics node with the given text.

default final @NonNull SemanticsNodeInteraction
FindersKt.onRoot(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    boolean useUnmergedTree
)

Finds the root semantics node of the Compose tree.

Public methods

onAllNodes

abstract @NonNull SemanticsNodeInteractionCollection onAllNodes(@NonNull SemanticsMatcher matcher, boolean useUnmergedTree)

Finds all semantics nodes that match the given condition.

If you are working with elements that are not supposed to occur multiple times use onNode instead.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
@NonNull SemanticsMatcher matcher

Matcher used for filtering.

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onNode

onNode

abstract @NonNull SemanticsNodeInteraction onNode(@NonNull SemanticsMatcher matcher, boolean useUnmergedTree)

Finds a semantics node that matches the given condition.

Any subsequent operation on its result will expect exactly one element found (unless SemanticsNodeInteraction.assertDoesNotExist is used) and will throw AssertionError if none or more than one element is found.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
@NonNull SemanticsMatcher matcher

Matcher used for filtering

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onAllNodes

to work with multiple elements

Extension functions

FindersKt.onAllNodesWithContentDescription

default final @NonNull SemanticsNodeInteractionCollection FindersKt.onAllNodesWithContentDescription(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String label,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds all semantics nodes with the given label as ContentDescription.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

FindersKt.onAllNodesWithTag

default final @NonNull SemanticsNodeInteractionCollection FindersKt.onAllNodesWithTag(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String testTag,
    boolean useUnmergedTree
)

Finds all semantics nodes identified by the given tag.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

FindersKt.onAllNodesWithText

default final @NonNull SemanticsNodeInteractionCollection FindersKt.onAllNodesWithText(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String text,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds all semantics nodes with the given text.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

FindersKt.onNodeWithContentDescription

default final @NonNull SemanticsNodeInteraction FindersKt.onNodeWithContentDescription(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String label,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds a semantics node with the given contentDescription.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onNode

for general find method.

FindersKt.onNodeWithTag

default final @NonNull SemanticsNodeInteraction FindersKt.onNodeWithTag(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String testTag,
    boolean useUnmergedTree
)

Finds a semantics node identified by the given tag.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onNode

for general find method.

FindersKt.onNodeWithText

default final @NonNull SemanticsNodeInteraction FindersKt.onNodeWithText(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    @NonNull String text,
    boolean substring,
    boolean ignoreCase,
    boolean useUnmergedTree
)

Finds a semantics node with the given text.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean substring

Whether to use substring matching.

boolean ignoreCase

Whether case should be ignored.

boolean useUnmergedTree

Find within merged composables like Buttons.

See also
onNode

for general find method.

FindersKt.onRoot

default final @NonNull SemanticsNodeInteraction FindersKt.onRoot(
    @NonNull SemanticsNodeInteractionsProvider receiver,
    boolean useUnmergedTree
)

Finds the root semantics node of the Compose tree.

Useful for example for screenshot tests of the entire scene.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
boolean useUnmergedTree

Find within merged composables like Buttons.