Cannot find elements on the page the was develop with JetPack Compose

I have an Android app where some pages are developed with JetPack Compose.
My dev said that are added (Modifier.semantics { testTagsAsResourceId = true }

But I still cant use ids that provide me my devs:

I found that I need to add new dependencies:
implementation ‘androidx.compose.ui:ui:1.3.0’
implementation ‘androidx.compose.ui:ui-tooling:1.3.0’
implementation ‘androidx.test.ext:junit:1.1.3’
implementation ‘androidx.test.espresso:espresso-core:3.5.1’
implementation ‘androidx.test.espresso:espresso-contrib:3.5.1’

but I still have a problem with - Cannot resolve symbol 'androidx and with this - import androidx.compose.ui.test.junit5.AndroidComposeTestRule;

But I’m using Appim driver so do I need espresso?
but even after adding everything I cant use ids in this way:

@AndroidFindBy(uiAutomator = “new UiSelector().resourceId(‘pricesDropDownIcon’)”)
protected WebElement myButton;

What did I do wrong?



try it with

    @AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"pricesDropDownIcon\")")
    private WebElement andrewButton;

PS I believe in your Appium Debug logs there is log that your locator just not valid to execute it.

im not sure what can we do. Should I talk with my dev to fix it or is this my problem -

And from the log i can see that i dont see my “pricesDropDownIcon” button - but I can see some numbers like - “ELEMENT”:“00000000-0000-027d-ffff-ffff00000081”. So does it mean that the problem on the dev side?


In logs you do not try ty find element with id pricesDropDownIcon.

Check again your code. After fail find get page source and check again - what you looking for…

How is it possible if im looking for the element with this:

@AndroidFindBy(uiAutomator = “new UiSelector().resourceId(“”) && new UiSelector().clickable(true)”)
private WebElement andrewButton;

after that I have a method:

public void clickButton(){;

Do I need some more?
As you said I used the method for checking what do I see

And I don’t see anything at all. I mean no buttons no ids at all

as i understood that the problem is not from my side cause i dont see any - at all

I do not understand.

You wrote about “pricesDropDownIcon” while in logs no such search attempt. Now you switch to “toolbarBackButton”. While in your code you writing wrong syntax that will not execute.

So pls all together again:

  • what element you looking for
  • what in page source - link to gist
  • what code you wrote.
  • what in appium server debug logs - link to gist

Sorry i was looking for another way to use the element. But couldnt)


  1. id - pricesDropDownIcon
  2. System.out.println(AppiumInit.getAppiumDriver().getPageSource()); -

it is on the 21st line I think
3. My code is:
public class PricesCurrencyPage {
AppiumDriver driver;

public PricesCurrencyPage(AppiumDriver driver){
    driver = driver;
    PageFactory.initElements(driver, this);
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"pricesDropDownIcon\")")
private WebElement dropDownButton;

public void clickDropDownButton(){;


As far as I understood the problem is - I don’t see id - pricesDropDownIcon after System.out.println(AppiumInit.getAppiumDriver().getPageSource());
Am I right? But how is to possible if I can see it in inspector?

  1. in your page source your pricesDropDownIcon absent. Ask dev why? now it has only. Possibly you use different builds…
<android.widget.Button index="1" package="com.dkveuroservice.mobileappkit" class="android.widget.Button" text="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="false" long-clickable="false" password="false" scrollable="false" selected="false" bounds="[1188,491][1356,659]" displayed="true" />

This is NOT correct UiSelector code! It should be like

new UiSelector().resourceId(“”).clickable(true)
  1. In your Appium logs no search for toolbarBackButton element. Also in page source mentioned in 2 reponse no toolbarBackButton id :frowning:

BTW test also

@AndroidFindBy(uiAutomator = "new UiSelector().resourceIdMatches(\".* pricesDropDownIcon\")")

possibly you have the case of → [Android] Testing Compose layout · Issue #15138 · appium/appium · GitHub

o im sorry i didnt change it. Now i changed it but the result is the same
So yes i was right about the id on the source page.

so do you think we need to add -
but we did it with backButton -

and as you can see from the code -

I cant find it as well

I use appium to test an app written in jetpack compose. Like you I had to get my devs to add TestTag and to set testTagsAsResourceId = true.

This worked and I could now see the resource ids in Appium Inspector. However many times I was still unable to get the element by ID using UIAutomator and the .NET appium client. As a workaround I get android elements by XPath using something like


This works and is reliable and stable. I’m not sure if there are performance implications though.

Since I use .NET my syntax will not be the same as yours, but I found that I can get by ID id I use the following syntax:

Driver.FindElement("id", "my-element")

But it doesn’t work if I use


I think there is a bug there. I thought it was in the .NET client but maybe not after seeing your issue. Anyway, for the most part I use the attributes on the Page Object to find my elements like you do. This does not work to get Id so it ends up looking something like this:

[FindsBy(How = How.XPath, Using = "//*[@resource-id='pricesDropDownIcon']")]
private IWebElement dropDownButton;

That’s .Net code but I’m sure you can easily convert to Java

1 Like

cause Appium add package name by default. So you need either

  • ask DEV to add it also to testTag
  • or ask Appium not add package name it in settings
  • or use uiAutomator = "new UiSelector().resourceId(....

one quick question - can i use System.out.println(AppiumInit.getAppiumDriver().getPageSource()); for checking the native part? cause as far as I found in google - this method only for webview context?

I use it most of times. Last time used Appium UI … 5y ago

PS with job fail I am adding it to check locators if they changed. Example of fail with Allure report ->

1 Like