PLEASE ADVISE!... Successfully executing test code BUT not finding any elements

I am currently wrestling with the running some Android Automation tests using an Android Emulator. My tests are all written in Javascript, and I have had them execute before, both through the emulator as well as a real device, but that was a few months ago, not to mention the fact that I have had to switch laptops since then (which I am guessing may have created an issue or two).

At this point, I am able to launch my Android App through the Appium GUI OR the command line (Mac), and I can execute my test script via the command line just fine, but, I am not able to find ANY of the elements on the Emulator. I currently do not have the same device that I was using as a co-worker has been using it, and ultimately I would like to be able to run the tests that way too, but one thing at a time…

My Appium Android settings are as such…


And in my script I have my settings as such…

An example of the output I am getting…

Thoughts?? Thank you

Firstly, since it’s been a few months, would you agree that it’s safe to say that this app has changed significantly since these tests were working?

Secondly, I can see from your logs that you are using ‘xpath’ as your find strategy. IMHO, xpath is a very brittle strategy, and I would not expect your tests to work with even slight changes to the app. You will have to rewrite these tests and figure out what the xpaths have changed to. I would suggest that a long term solution is to change your find strategy to something that will be more flexible as your app changes. Something like finding element by name/id/text–you’ll probably need a combination of all these. IMHO you should only use xpath as a last resort.

1 Like

I totally hear you, and thought about that. I am currently using the exact same build as I was using before, so none of the elements should have changed. And as far as using the name/id/text, for some reason that is not an option for me. None of the elements on the app have unique IDs or names, and while using the appium inspector it was virtually impossible to find any element via the text. Sigh… this is becoming quite a fiasco

Why don’t you inspect elements again once using uiautomatorviewer with emulator screen to see exact reason of xpaths being failing

Also it is always reliable to use classNames,id, etc which usually do not change with change in element hierarchy/positions.

Also u can give observation of below points

  1. Emulator is created with which API level
  2. Does you app support that specific API level
1 Like

When I open up the inspector, there are no classNames or ids for the elements. There have only been a couple of elements with those available, and those are elements I really don’t use. I think that when our app was being built that the team building it did not include such tags with the elements, but I also don’t know how that process is done, so I am not sure. All I know is that XPATH is currently the only way that I have been able to find anything through Appium.