I am using Jetpack Compose and Appium with UIAutomator. I would like to set a unique id
for the Composables instead of showing the Xpath because of:
Using XPath locators is not recommended and can lead to fragile tests. Ask your development team to provide unique accessibility locators instead.
Inside Android Studio under my Composable I have added:
Row(
modifier = Modifier.semantics { testTagsAsResourceId = true }
...
) {
Text(
modifier = Modifier.semantics { testTag = "testTag" },
Now in Appium I can see that the resource-id
= testTag, but the id
is still showing the Xpath.
According to this article I should be able to set the id
to the same as resource-id
by using @AndroidFindBy
and some class UiSelector
but I do not understand how - should I add this annotation inside my Composable?
I read about a solution here but Espresso is not an option for me, unfortunately.
I also tried using:
modifier = Modifier.semantics { this.contentDescription = "testTag" },
And this actually changed the Xpath, but still it showed the warning above.
This is how I would like to have it (where id and resource-id has the same value): image from article