I am testing the Tiktok app.
I am not the owner of this app.
Every app update the resource ID names get updated with new names.
What is the best solution to fetch elements without resource id and keep of stable testing?
CodePudding user response:
The resource id name is changing because the app is obfuscated and every time you obfuscate the app new identifiers are generated for resource ids, class names, field names, variable names, method names, ...
To identify a certain UI element you can try to assume the UI does not change much which means you are trying to specify the element in their order, e.g. the 2nd button. I am not sure if the layout inspector still works this handy tool of Android Studio was able to read out the current shown layout with all the UI elements and their names and types.
Alternatively you can try to parse the layout and/or fragment XML files. If their file name is obfuscated, too you could identify the relevant layout XML file once by hand and next time compare all the layout cml files of the old and the new app versions and order them how close they are to each other on text level. The closest match to the file you have identified by hand is most likely the layout xml file you are searching for.
CodePudding user response:
Use user-facing selectors like text or even content description when available (if the app is well designed it would be what the screen readers see).
If you are not the app owner, you should not rely on stuff you can't control like ids.