Android Compose `mergeDescendants`
Maestro doesn't recognize merged accessibility content from Compose mergeDescendants
Is there an existing issue for this?
- [x] I have searched the existing issues and didn't find mine.
Problem Description
Maestro cannot find elements by their merged accessibility text when using Android Compose's mergeDescendants = true semantics modifier, even though screen readers and Android's Layout Inspector correctly recognize the merged content.
This creates a gap between what accessibility tools see and what Maestro can test, which is particularly important for compliance with the European Accessibility Act and AndroidTV accessibility requirements.
Steps to Reproduce
- Create a Compose layout with merged descendants:
Column(modifier = Modifier.semantics(mergeDescendants = true) {}) {
Text("Line 1")
Text("Line 2")
}
-
Verify the merging works correctly:
- TalkBack announces: "Line 1, Line 2"
- Layout Inspector shows merged content
- Column receives focus as expected
-
Try to test with Maestro:
- assertVisible:
text: "Line 1, Line 2"
focused: true
Actual Results
Test fails - Maestro cannot find an element with text "Line 1, Line 2"
Maestro hierarchy output:
{
"attributes": {
"text": "",
"accessibilityText": "",
"hintText": "",
"focused": "true",
"class": "android.view.View"
},
"children": [
{
"attributes": {
"text": "Line 1",
"accessibilityText": "",
"hintText": "",
"focused": "false",
"class": "android.widget.TextView"
}
},
{
"attributes": {
"text": "Line 2",
"accessibilityText": "",
"hintText": "",
"focused": "false",
"class": "android.widget.TextView"
}
}
]
}
Issue: The focused Column element shows empty text, accessibilityText, and hintText fields, while child elements contain the individual text values but aren't focused.
Expected Results
Maestro should recognize the merged accessibility content and allow assertions like:
- assertVisible:
text: "Line 1, Line 2"
focused: true
This should work consistently with how Android's accessibility services and internal tooling handle mergeDescendants.
Environment
App Details:
- Closed source native Android app
- Compose UI (minSdk: 26, targetSdk: 35)
Development Environment:
- OpenJDK 17.0.6 (Temurin)
- macOS 15.3.1 (Apple Silicon M1)
- Maestro 2.0.2 (installed via https://get.maestro.mobile.dev)
Reference
Suspect this is related to the issue being tracked in #2651
Can you provide the output of maestro hierarchy?
I already did but it was in a collapsible section. I have edited the original issue to expose the JSON
I fear that isn't something within Maestro's control. Maestro knows nothing of Android Compose.
Maestro uses the UiAutomator and InstrumentationRegistry APIs to enumerate what's on the screen, so that hierarchy is Maestro's representation of what the OS is telling it is on the screen.
Unsure if this approach is useful in your context?
Unfortunately we want to test what a user actually sees/hears with accessibility API. Attaching a test tag would defeat the purpose.