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.
First make sure the change is actually in the build you’re spying on. testTagsAsResourceId is only available in newer Compose versions, so if your dev can’t use it, upgrade Compose first. After adding the flag, ship a new build, reinstall the app and refresh the page source in Mobile Spy.
As far as I know, dialogs, bottom sheets and popups are separate windows, so the flag on the screen root doesn’t reach them. Set it inside their content too.
If a tag sits on a child inside a clickable or merged parent (e.g. a Text inside a Button), the merged node may only expose the parent’s tag. Put the tag on the parent, or avoid merging for that element.
To separate app-side issues from Katalon-side ones, dump the screen directly: adb shell uiautomator dump /sdcard/window.xml, pull the file and search for your tag in resource-id. If it’s there, Mobile Spy will see it too.