Nauman Malik
Nauman Malik

Reputation: 188

UIAutomatorViewer showing same resource id's

I have been doing Android Automation for an app using Appium. Everyday a new build comes of the app and I have to check the code for new fixes using Automation. The problem I am facing is that in a current new build of the app the resource id's of all the buttons and fields that I need to access in automation has become same. I could use Xpaths to access certain elements but using Xpath's will make automation slow.

I use UIAutomatorViewer to get Xpath's and resource id's.

Can somebody help me in determining if the same resource id issue that I am facing is at the Android end or if my UIAutomator is not working correctly and showing same id's?

For security purposes I cannot share the screenshot.

Upvotes: 4

Views: 1255

Answers (2)

Rajesh Chaudhary
Rajesh Chaudhary

Reputation: 112

I ask my devs to always put ids of all the items in the screen for automation purpose. Also check with devs if in some case they are not able to do so then xpath can be used in some cases.

Upvotes: 1

Suban Dhyako
Suban Dhyako

Reputation: 2526

Using Xpath is not recommended. The reason is that the infrastructure used to generate the XPath, doesn't guarantee that the XPath will remain the same between two different executions.

The only solution i see to your problem is to ask developer to add unique automation id for each element. You can ask them to put unique cont-desc in their code. Then you will be able to access element using findByAccessibilityId.

MobileElement element = driver.findElementByAccessibilityId("SomeAccessibilityID");

Upvotes: 1

Related Questions