4

after obfuscating the apk with dexguard ,elements resource ids are not visible in uiautomator tool.

can the dexguard release build used for automation? how to keep the elements resource ids for dexguard release build?

Ashok Kumar
  • 1,226
  • 1
  • 10
  • 14

2 Answers2

2

-keepresources id/** did the trick.

Ashok Kumar
  • 1,226
  • 1
  • 10
  • 14
0

Yes. I have automated many applications which have few, if any resource-id's. Even those that do use resource-id's keep in mind that unlike in HTML they are not always unique - many elements can contain the same resource-id anyway.

If I am provided with a resource-id and I've examined the page elements closely and see that the id is unique, I'll often use it. Elements are often more-consistently found using XPaths, in my opinion, which allows a much more detailed locator.

More often than not, I'll do something like

"//android.widget.TextView[@text='whatever']

or further:

"//android.widget.TextView[@text='whatever' and @index=1]"
Bill Hileman
  • 2,798
  • 2
  • 17
  • 24
  • But my query is that we have a native android application which is obfuscated with dexguard. after obfuscation uiautomator is unable to see the resource ids. we have keep the resource ids configuration in dexguard config file but still the resource ids are not visible. have you done automation on obfucated native release apk? – Ashok Kumar Aug 04 '17 at 08:59
  • @Eric Lafortune any suggestion? – Ashok Kumar Aug 04 '17 at 10:27
  • I am not directly familiar with the obfuscator. Does it hide more than the resource-id's? The point of my answer is that you don't necessarily have to have resource-id's to form usable locators. Or are you doing something else that requires the resource-id's? – Bill Hileman Aug 04 '17 at 13:29
  • yes we need resource ids for automation and it is native app.also dexguard is hiding all the resource ids which are also required for automation. – Ashok Kumar Aug 07 '17 at 09:01
  • If you're using Appium, why are the resource-id's "required?" Appium is capable of automating without resource-id's. – Bill Hileman Aug 07 '17 at 13:10
  • 1
    we are using resource ids to interact with elements. are you referring xpath as work around? could you please provide solution if we have to use resource ids? – Ashok Kumar Aug 10 '17 at 05:22