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.

DesktopComposeTestRule
DesktopComposeUiTest

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 ContentDescription.

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 contentDescription.

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

Find within merged composables like Buttons.

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

Find within merged composables like Buttons.

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 ContentDescription.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
substring: Boolean = false

Whether to use substring matching.

ignoreCase: Boolean = false

Whether case should be ignored.

useUnmergedTree: Boolean = false

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

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

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

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

Whether to use substring matching.

ignoreCase: Boolean = false

Whether case should be ignored.

useUnmergedTree: Boolean = false

Find within merged composables like Buttons.

See also
onAllNodes

for general find method.

onNodeWithContentDescription

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

Finds a semantics node with the given contentDescription.

For usage patterns and semantics concepts see SemanticsNodeInteraction

Parameters
substring: Boolean = false

Whether to use substring matching.

ignoreCase: Boolean = false

Whether case should be ignored.

useUnmergedTree: Boolean = false

Find within merged composables like Buttons.

See also
onNode

for general find method.

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

Find within merged composables like Buttons.

See also
onNode

for general find method.

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

Whether to use substring matching.

ignoreCase: Boolean = false

Whether case should be ignored.

useUnmergedTree: Boolean = false

Find within merged composables like Buttons.

See also
onNode

for general find method.

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

Find within merged composables like Buttons.