# SubspaceSemanticsNodeInteractionCollection

Artifact: [androidx.xr.compose:compose-testing](https://developer.android.com/jetpack/androidx/releases/xr-compose) [View Source](https://cs.android.com/search?q=file:androidx/xr/compose/testing/SubspaceSemanticsNodeInteraction.kt+class:androidx.xr.compose.testing.SubspaceSemanticsNodeInteractionCollection) Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)


```
class SubspaceSemanticsNodeInteractionCollection
```

<br />

*** ** * ** ***

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

One can interact with these nodes by fetching their semantics information or accessing a specific node via its index. An instance of this collection can be obtained from `onAllSubspaceNodes` and convenience methods that use a specific filter, such as `onAllSubspaceNodesWithTag`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsNodeInteractionCollection#SubspaceSemanticsNodeInteractionCollection(androidx.xr.compose.testing.SubspaceTestContext,androidx.xr.compose.testing.SubspaceSemanticsMatcher)( testContext: https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceTestContext, matcher: https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsMatcher )` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/node/SubspaceSemanticsInfo>` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsNodeInteractionCollection#fetchSemanticsNodes(kotlin.Boolean,kotlin.String)( atLeastOneRootRequired: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, errorMessageOnFail: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? )` Returns the list of semantics nodes captured by this collection. |
| `operator https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsNodeInteraction` | `https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsNodeInteractionCollection#get(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Retrieves the interaction for the node at the given index in this collection. |

## Public constructors

### SubspaceSemanticsNodeInteractionCollection

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
SubspaceSemanticsNodeInteractionCollection(
    testContext: SubspaceTestContext,
    matcher: SubspaceSemanticsMatcher
)
```

## Public functions

### fetchSemanticsNodes

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
fun fetchSemanticsNodes(
    atLeastOneRootRequired: Boolean = true,
    errorMessageOnFail: String? = null
): List<SubspaceSemanticsInfo>
```

Returns the list of semantics nodes captured by this collection.

This operation involves synchronization with the UI to fetch the latest node data. If accessed multiple times in a single atomic operation, caching the result is recommended to avoid performance overhead.

| Parameters |
|---|---|
| `atLeastOneRootRequired: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | whether to throw an error if there is no compose content found in the current test application. |
| `errorMessageOnFail: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html? = null` | the prefix to be added to the error message if the fetch operation fails. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/node/SubspaceSemanticsInfo>` | the list of matched `SubspaceSemanticsInfo` instances. |

### get

Added in [1.0.0-beta02](https://developer.android.com/jetpack/androidx/releases/xr-compose#1.0.0-beta02)

```
operator fun get(index: Int): SubspaceSemanticsNodeInteraction
```

Retrieves the interaction for the node at the given index in this collection.

Any subsequent operation on the returned interaction will expect exactly one element to be found (unless `SubspaceSemanticsNodeInteraction.assertDoesNotExist` is used) and will fail if zero or multiple elements are found.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the zero-based index of the node to retrieve from the matched collection. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/testing/SubspaceSemanticsNodeInteraction` | the interaction corresponding to the node at the specified index. |