Composables UI is out: our new component library for Compose Multiplatform ->
Function

assertTextContains

Asserts that the node's list of text values contains the given value.

assertTextContains

Source set: Common
fun SemanticsNodeInteraction.assertTextContains(
    value: String,
    substring: Boolean = false,
    ignoreCase: Boolean = false,
): SemanticsNodeInteraction

Asserts that the node's list of text values contains the given value.

This will also search in SemanticsProperties.EditableText and SemanticsProperties.InputText.

The Text property is represented as a list of strings. In the merged semantics tree (the default in Compose testing), this list often contains multiple text items merged from child nodes. This function evaluates whether any individual item in that list matches the provided value.

By default, this requires an exact string match with at least one complete item in the list.

Typically, accessibility tooling will decide based on its heuristics which ones to use.

Throws AssertionError if the node's value list does not contain value, or if the node has no value.

Parameters

value Value to match against the items in the list of text values.
substring Whether this can be satisfied as a substring match of an item in the list of text. Defaults to false.
ignoreCase Whether case should be ignored. Defaults to false.

Last updated: