SemanticsNodeInteractionsProvider

Known direct subclasses
ComposeTestRule

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

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 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 functions

SemanticsNodeInteractionCollection
onAllNodes(matcher: SemanticsMatcher, useUnmergedTree: Boolean)

Finds all semantics nodes that match the given condition.

Cmn
SemanticsNodeInteraction
onNode(matcher: SemanticsMatcher, useUnmergedTree: Boolean)

Finds a semantics node that matches the given condition.

Cmn

Extension functions

SemanticsNodeInteractionCollection
SemanticsNodeInteractionsProvider.onAllNodesWithContentDescription(
    label: String,
    substring: Boolean,
    ignoreCase: Boolean,
    useUnmergedTree: Boolean
)

Finds all semantics nodes with the given label as content description.

Cmn
SemanticsNodeInteractionCollection
SemanticsNodeInteractionsProvider.onAllNodesWithTag(
    testTag: String,
    useUnmergedTree: Boolean
)

Finds all semantics nodes identified by the given tag.

Cmn
SemanticsNodeInteractionCollection
SemanticsNodeInteractionsProvider.onAllNodesWithText(
    text: String,
    substring: Boolean,
    ignoreCase: Boolean,
    useUnmergedTree: Boolean
)

Finds all semantics nodes with the given text.

Cmn
SemanticsNodeInteraction
SemanticsNodeInteractionsProvider.onNodeWithContentDescription(
    label: String,
    substring: Boolean,
    ignoreCase: Boolean,
    useUnmergedTree: Boolean
)

Finds a semantics node with the given content description.

Cmn
SemanticsNodeInteraction
SemanticsNodeInteractionsProvider.onNodeWithTag(
    testTag: String,
    useUnmergedTree: Boolean
)

Finds a semantics node identified by the given tag.

Cmn
SemanticsNodeInteraction
SemanticsNodeInteractionsProvider.onNodeWithText(
    text: String,
    substring: Boolean,
    ignoreCase: Boolean,
    useUnmergedTree: Boolean
)

Finds a semantics node with the given text.

Cmn
SemanticsNodeInteraction

Finds the root semantics node of the Compose tree.

Cmn

Public functions

onAllNodes

fun onAllNodes(matcher: SemanticsMatcher, useUnmergedTree: Boolean = false): SemanticsNodeInteractionCollection

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
matcher: SemanticsMatcher

Matcher used for filtering.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree. This allows you to search for individual nodes that would otherwise be part of a larger semantic unit, for example a text and an image forming a Button together.

See also
onNode

onNode

fun onNode(matcher: SemanticsMatcher, useUnmergedTree: Boolean = false): SemanticsNodeInteraction

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 an AssertionError if none or more than one element is found.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
matcher: SemanticsMatcher

Matcher used for filtering

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree. This allows you to search for individual nodes that would otherwise be part of a larger semantic unit, for example a text and an image forming a Button together.

See also
onAllNodes

to work with multiple elements

Extension functions

onAllNodesWithContentDescription

fun SemanticsNodeInteractionsProvider.onAllNodesWithContentDescription(
    label: String,
    substring: Boolean = false,
    ignoreCase: Boolean = false,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteractionCollection

Finds all semantics nodes with the given label as content description.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
label: String

The text to search for.

substring: Boolean = false

If true, allows matches where the label is a substring of the content description.

ignoreCase: Boolean = false

If true, does a case-insensitive search.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onAllNodes

for more information.

onAllNodesWithTag

fun SemanticsNodeInteractionsProvider.onAllNodesWithTag(
    testTag: String,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteractionCollection

Finds all semantics nodes identified by the given tag.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
testTag: String

The tag to search for. Looks for exact matches only.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onAllNodes

for more information.

onAllNodesWithText

fun SemanticsNodeInteractionsProvider.onAllNodesWithText(
    text: String,
    substring: Boolean = false,
    ignoreCase: Boolean = false,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteractionCollection

Finds all semantics nodes with the given text.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
text: String

The text to search for.

substring: Boolean = false

If true, allows matches where the label is a substring of the content description.

ignoreCase: Boolean = false

If true, does a case-insensitive search.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onAllNodes

for more information.

onNodeWithContentDescription

fun SemanticsNodeInteractionsProvider.onNodeWithContentDescription(
    label: String,
    substring: Boolean = false,
    ignoreCase: Boolean = false,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteraction

Finds a semantics node with the given content description.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
label: String

The text to search for.

substring: Boolean = false

If true, allows matches where the label is a substring of the content description.

ignoreCase: Boolean = false

If true, does a case-insensitive search.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onNode

for more information.

onNodeWithTag

fun SemanticsNodeInteractionsProvider.onNodeWithTag(
    testTag: String,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteraction

Finds a semantics node identified by the given tag.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
testTag: String

The tag to search for. Looks for an exact match only.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onNode

for more information.

onNodeWithText

fun SemanticsNodeInteractionsProvider.onNodeWithText(
    text: String,
    substring: Boolean = false,
    ignoreCase: Boolean = false,
    useUnmergedTree: Boolean = false
): SemanticsNodeInteraction

Finds a semantics node with the given text.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
text: String

The text to search for.

substring: Boolean = false

If true, allows matches where the label is a substring of the content description.

ignoreCase: Boolean = false

If true, does a case-insensitive search.

useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.

See also
onNode

for more information.

fun SemanticsNodeInteractionsProvider.onRoot(
    useUnmergedTree: Boolean = false
): SemanticsNodeInteraction

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
useUnmergedTree: Boolean = false

If true, searches the unmerged semantics tree instead of the merged semantics tree.