I’m redoing the tests in the application that previously used XML to create screen objects. Jetpack compose has been implemented. As a result, screen objects are no longer identified as before by the appium inspector.
To display the ID of the screen objects again, assign the testTag property to the semantics, like this: Modifier.semantics {testTag = “tagFab” testTagsAsResourceId = true}
With that, the FAB (floating action button) assumed the ID that was passed in the tag (tagFab).
However, when I trigger the FAB through the name I assigned to the testTag, it is not identified. I’m looking for the FAB through findElement(By.id()).
I’ve implemented these two ways: appiumDriver!!.findElements(By.id("br.com.myapp:id/tagFab"))
or appiumDriver!!.findElements(By.id("tagFab"))
However, both options always return the same message: org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters.
What is the problem or what am I doing wrong so that the object is not being identified? Thank you in advance for your attention.
However, I found this article detailing some changes to Appium Espresso driver to help with JetPack compose automation informative. Maybe it will help you:
So I’ve seen this example before. But it only talks about configuring the appium driver for compose. Thing I already did. Even so, it still does not identify the object on the screen.
Hi, i had the same problem, you have to use UiSelector : driver.findElement(AppiumBy.androidUIAutomator(“new UiSelector().resourceId(“fab”)”)).click();
Hi, wilkegutierre …yes in my code there are slashes but I don’t know why they are not seen. driver.findElement(AppiumBy.androidUIAutomator("new UiSelector().resourceId(\"your resource-id\")")).click();
my driver is not AppiumDriver but AndroidDriver and you have to write only your id no the package.
Hi Aleksei.
Thank you for your attention, my dear.
I forgot to mention in the Giuma answer post that I implemented it with and without a package name. In the code you can see that it is with the package name, but I also tried without. As well, I was using AppiumDriver and not AndroidDriver. I’ll try without the package name and with the AndroidDriver.
I already tried it without the package name and it didn’t find the element. However, I was using AppiumDriver. I’ll try with the AndroidDriver and without the package name like you said.
I hope it works, in case it still doesn’t , are you sure that id is in the right component? if you need to get the plus button id you need to get the resouce-id of the android.widget.button class in your screenshot i see the wrong class id.
Add more details what does not work. Element not found. Tap did but nothing happens. Enable in debug mode to show on phone where touch happens. Possibly ypu have same element in another place…
Hey guys!
I went back! And I came back to first thank all of you who collaborated with my question. And especially, thanks to @Giuma for showing me 60% of the problem I was having in identifying the compose element of the app screen.
In short: what I had to do was inform the testTagsAsResourceId property at the top of the composible elements tree and fetch the screen element through this way: