https://kotlinlang.org logo
Title
j

Jan Skrasek

02/01/2023, 10:18 AM
UI tests & semantics actions & merge descendants I have a wrapper Box with mergeDescendants=true and I hoped that triggering some actions on the box will properly pick the exposed semantic actions from its children, e.g. a Slider here. But it doesn't work, I have to "find the child" with the action. Is it expected?
Box(
    modifier = Modifier.testTag("slider").semantics(mergeDescendants = true) {},
    propagateMinConstraints = true,
) {
    androidx.compose.material3.Slider(...)
}

// this fails with "Failed to perform action SetProgress, the node is missing [SetProgress]"
composeTestRule.onNodeWithTag("slider").performSemanticsAction(SemanticsActions.SetProgress) { it.invoke(0.5f) }
Oh, so it's caused because the slider has own mergeDescendants and such nodes aren't merged again. 😞