Problem : I want to run an Appium script on the same application, but different builds.
All resource-Id in the application is appended with the package name
Eg: For build A , username text field is - alpha.beta.charlie.delta:id/user_name and
For build B username field alpha.beta.charlie/user_name , delta is removed from the package name.
I use AndroidFindBy from the page factory to locate the elements
private static final PACKAGE = "alpha.beta.charlie.delta"
@AndroidFindBy(id = PACKAGE + "/user_name")
private MobileElement username;
Where PACKAGE is declared as constant .
Now if I want to run the script on build B, I have to change the package name every time before I trigger the execution. Which is not efficient.
I know we can't add variables to pagefactory annotations.
The only workaround I see is using https://developer.android.com/reference/android/support/test/uiautomator/UiSelector.html#resourceidmatches
Is there any other workaround where I can add the package name at compile time to bypass changing package name manually.