Google is committed to advancing racial equity for Black communities. See how.

SemanticsNodeInteractionCollection

class SemanticsNodeInteractionCollection
kotlin.Any
   ↳ androidx.ui.test.SemanticsNodeInteractionCollection

Represents a collection of semantics nodes and the path to fetch them from the semantics tree. One can interact with these nodes by performing assertions such as assertCountEquals, or navigate to other nodes such as get.

This is usually obtained from methods like onAllNodes or chains of onNode.onChildren.

Example usage:

onAllNodes(isClickable())
   .assertCountEquals(2)

Summary

Public constructors
<init>(useUnmergedTree: Boolean, selector: SemanticsSelector)

Represents a collection of semantics nodes and the path to fetch them from the semantics tree.

Public methods
List<SemanticsNode>
fetchSemanticsNodes(errorMessageOnFail: String? = null)

Returns the semantics nodes captured by this object.

operator SemanticsNodeInteraction
get(index: Int)

Retrieve node at the given index of this collection.

Extension functions
From androidx.ui.test
SemanticsNodeInteractionCollection

Asserts that all the nodes in this collection satisfy the given matcher.

SemanticsNodeInteractionCollection

Asserts that this collection contains at least one element that satisfies the given matcher.

SemanticsNodeInteractionCollection

Asserts that this collection of nodes is equal to the given expectedSize.

SemanticsNodeInteractionCollection

Returns all the nodes matching the given matcher.

SemanticsNodeInteraction

Expects to return exactly one node matching the given matcher.

SemanticsNodeInteraction

Returns the first node in this collection.

SemanticsNodeInteraction

Returns the last node in this collection.

Unit
SemanticsNodeInteractionCollection.printToLog(tag: String, @IntRange(0) maxDepth: Int = 0)

Prints all the semantics nodes information into logs (as debug level).

String

Prints all the semantics nodes information it holds into string.

Public constructors

<init>

SemanticsNodeInteractionCollection(
    useUnmergedTree: Boolean,
    selector: SemanticsSelector)

Represents a collection of semantics nodes and the path to fetch them from the semantics tree. One can interact with these nodes by performing assertions such as assertCountEquals, or navigate to other nodes such as get.

This is usually obtained from methods like onAllNodes or chains of onNode.onChildren.

Example usage:

onAllNodes(isClickable())
   .assertCountEquals(2)

Public methods

fetchSemanticsNodes

fun fetchSemanticsNodes(errorMessageOnFail: String? = null): List<SemanticsNode>

Returns the semantics nodes captured by this object.

Note: Accessing this object involves synchronization with your UI. If you are accessing this multiple times in one atomic operation, it is better to cache the result instead of calling this API multiple times.

get

operator fun get(index: Int): SemanticsNodeInteraction

Retrieve node at the given index of this collection.

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.