---
title: "onSubspaceNode"
description: "Finds a semantics node in the Subspace hierarchy that matches the given condition."
type: "function"
lastmod: "2026-06-18T10:32:52.443528Z"
---
## API Reference

### onSubspaceNode

> Source set: Android

```kotlin
public fun AndroidComposeTestRule<*, *>.onSubspaceNode(
    matcher: SubspaceSemanticsMatcher
): SubspaceSemanticsNodeInteraction
```

Finds a semantics node in the Subspace hierarchy that matches the given condition.

This function only locates nodes within the Subspace hierarchy and does not include nodes from
standard 2D compose contexts. For example, it targets `SpatialPanel`, `SpatialRow`, or
`SpatialColumn` nodes but not standard `Row`, `Column`, or `Text` nodes. For locating 2D nodes,
use `AndroidComposeTestRule.onNode`.

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

#### Parameters

| | |
| --- | --- |
| matcher | the `SubspaceSemanticsMatcher` used to identify the matching semantics node. |

#### Returns

| | |
| --- | --- |
|  | the `SubspaceSemanticsNodeInteraction` for the matched node. |

## Code Examples
### subspaceNodeMatcherProperties
```kotlin
public fun subspaceNodeMatcherProperties() {
    composeTestRule.setContent {
        Subspace {
            SpatialPanel(SubspaceModifier.width(100.dp).height(100.dp).testTag("myPanel")) {}
        }
    }
    // Check existence and exact spatial dimensions in DP using semantic matchers
    composeTestRule
        .onSubspaceNodeWithTag("myPanel")
        .assertExists()
        .assertPositionInRootIsEqualTo(0.dp, 0.dp, 0.dp)
        .assertWidthIsEqualTo(100.toDp())
        .assertHeightIsEqualTo(100.toDp())
}
```
### subspacePanelRenderedAndInteractive
```kotlin
public fun subspacePanelRenderedAndInteractive() {
    var count = 0
    composeTestRule.setContent {
        Subspace {
            SpatialPanel(SubspaceModifier.testTag("spatialPanel")) {
                Button(onClick = { count++ }) { Text("Increment") }
            }
        }
    }
    // Assert subspace node existence, position, and dimensions in the Spatial hierarchy
    composeTestRule
        .onSubspaceNodeWithTag("spatialPanel")
        .assertExists()
        .assertPositionInRootIsEqualTo(0.toDp(), 0.toDp(), 0.toDp())
    // Interact with the 2D Compose node nested within the Spatial container
    composeTestRule.onNodeWithText("Increment").performClick()
    composeTestRule.waitForIdle()
    // Verify outcomes
    assert(count == 1)
}
```
