traversing-the-semantics-tree

Traverse Jetpack Compose semantics trees to locate related UI nodes.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill traversing-the-semantics-tree
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: traversing-the-semantics-tree
Source: https://github.com/skydoves/android-testing-skills/tree/main/compose/finders/traversing-the-semantics-tree
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill traversing-the-semantics-tree

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

When a Compose UI test can’t reliably find a node using a single matcher, this skill solves the problem of locating nodes by their structural relationships in the semantics tree (parent/child/sibling/ancestors) instead of relying on brittle assumptions.

Core Features & Use Cases

  • Semantics tree navigation via relationship operators like onParent(), onChildren(), onChild(), onChildAt(), onSibling(), onSiblings(), and onAncestors().
  • Safer narrowing with filterToOne(matcher) and positional selection using onFirst(), onLast(), and the collection [index] operator.
  • Guidance on common pitfalls: LazyColumn/LazyRow only include currently composed children, onChildren() is a snapshot, and useUnmergedTree is sticky across navigation.
  • Decision support on when to traverse vs when to add a stable testTag, and when to prefer semantics matchers (hasAnyAncestor/hasAnyDescendant).

Quick Start

Use this skill to ask an AI how to find the second child of a Row that contains no stable testTag so you can assert what that sibling/relative node should look like.

Frequently Asked Questions about traversing-the-semantics-tree

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find a parent or sibling node in a Jetpack Compose UI test?

To find a parent or sibling node in Jetpack Compose UI testing, traverse the semantics tree using relationship operators like onParent(), onSibling(), and onAncestors() instead of relying on brittle index-based assumptions. This locates relative nodes structurally when single matchers fail.

What is the best way to test a Compose node when I can't use a stable testTag?

The best way to test a Compose node without a stable testTag is navigating the semantics tree by structural relationships. You can use operators like onChildren() or onChildAt() alongside filterToOne(matcher) to safely narrow down and assert the target node.

Why does onChildren() not find all items in a LazyColumn during Compose UI testing?

onChildren() does not find all items in a LazyColumn because LazyColumn and LazyRow only include currently composed children in the semantics tree. The onChildren() operator captures a snapshot, meaning off-screen items that are not composed will not be found.

When should I traverse the semantics tree versus using semantics matchers in Compose tests?

You should traverse the semantics tree when dealing with complex structural relationships like finding an nth child or sibling. Prefer semantics matchers like hasAnyAncestor or hasAnyDescendant when checking for specific properties across the tree, and add a stable testTag whenever possible to avoid brittle navigation.

Can I use useUnmergedTree for a single semantics traversal operation in Jetpack Compose?

You can apply useUnmergedTree for semantics traversal, but it is sticky across subsequent navigation operations. Once enabled, it persists throughout the node traversal chain, affecting how all downstream parent, child, and sibling nodes are evaluated in the semantics tree.