We are working on an Android app built with Jetpack Compose, and we want to identify elements using testTag so that they can be inspected and automated with Katalon Studio Mobile Spy.
Text(
text = "Product Details",
color = AppColors.colorTextInputError,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.testTag("tvTitle"),
)
Using layoutId with testTag:
Text(
text = "Product Details",
color = AppColors.colorTextInputError,
style = MaterialTheme.typography.bodySmall,
modifier = Modifier.layoutId("tvTitleLayoutId").testTag("tvTitle"),
)
However, in all cases, Katalon Mobile Spy is not able to detect or show these elements with testTag.
Instead, only generic or parent container nodes are visible, making it very hard to locate elements for automation.
Question:
Does Katalon Mobile Spy support inspecting testTag attributes from Jetpack Compose?
If not, is there any workaround (e.g., mapping testTag to accessibilityId, contentDescription, or resource-id) so that Katalon can recognize the elements?
Has anyone successfully integrated Katalon with Jetpack Compose apps for element inspection and test automation?
Any guidance or workaround would be greatly appreciated
@ashwini this is not a katalon thing, it is how compose exposes semantics to the accessibility tree. testTag alone is not sent to uiautomator, so appium (and therefore mobile spy) never sees it. you need one extra flag on the root of the screen:
testTagsAsResourceId is in androidx.compose.ui.semantics (it is marked experimental, so your dev adds @OptIn(ExperimentalComposeUiApi::class)). once it is set on an ancestor, every testTag below it shows up as resource-id in the uiautomator2 page source. in mobile spy you then get tvTitle under resource-id and can use id or //*[@resource-id='tvTitle'] as the locator. it only needs to be set once per root composable, not per element.
contentDescription works too and shows up as accessibility id, but it is read out by talkback, so devs usually prefer not to abuse it for test ids. testTagsAsResourceId is the clean route.