traversing-the-semantics-tree
Installation
SKILL.md
Traversing the Semantics Tree — When a Single Finder Won't Reach the Node
The single-finder shortcuts (onNodeWithTag, etc.) cover ~95% of test queries. The remainder need tree navigation: "the parent of this Text", "the third child of this Row", "any sibling that is enabled". This skill maps those navigation operators, calls out the LazyColumn snapshot caveat, and shows when traversal is the wrong tool.
When to use this skill
- The target node has no stable
testTagand one cannot be added to production (third-party composable, dynamically generated children). - The test verifies structural relationships ("the second child of the row is the icon").
- The developer chains
.onChildren()[i].onChildAt(j)and wants to know whether that is the right shape. - The developer mentions
onChildren,onChild,onParent,onSibling,onSiblings,onAncestors,filterToOne,onFirst,onLast, or[index]. - A
LazyColumntest misses items because they are off-screen.
When NOT to use this skill
- A
Modifier.testTag(...)could be added to the target node — adding a tag is almost always cleaner than a traversal chain. See../finding-nodes-by-tag-text-content/SKILL.md. - The relationship is "anywhere above" / "anywhere below" — prefer the matcher-based
hasAnyAncestor/hasAnyDescendant(see../composing-semantics-matchers/SKILL.md). - The query is about a LazyColumn item by key — use
performScrollToKeyinstead (see../../actions/clicking-and-scrolling/SKILL.md,../../patterns/testing-lazy-lists/SKILL.md).