mattinger
04/13/2026, 2:59 PM/***
* Returns a matcher that matches if the node has any ancestor matching the
* given interaction's node id.
*/
fun hasAnyAncestorNode(interaction: SemanticsNodeInteraction) = hasAnyAncestor(
SemanticsMatcher("hasAnyAncestorNode: ${interaction}") { node ->
node.id == interaction.fetchSemanticsNode().id
}
)
And example usage is looking for the "picker" node on a material DatePicker:
interactionProvider.onNode(
hasTestTag("picker").and(hasAnyAncestorNode(interaction))
)
However, i'm running into this error when it executes fetchSemanticsNode:
java.lang.IllegalStateException: Functions that involve synchronization (Assertions, Actions, Synchronization; e.g. assertIsSelected(), doClick(), runOnIdle()) cannot be run from the main thread. Did you nest such a function inside runOnIdle {}, runOnUiThread {} or setContent {}?
I'm wondering what the right way is to update this for compose 1.10shikasd
04/13/2026, 7:49 PMmattinger
04/14/2026, 1:44 PMhasAnyAncester(hasNodeId(interaction.fetchSemanticsNode().id))
hasNodeId is a pretty simple matcher.