Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99410

How to change the package name in AndroidFindBy annotation

$
0
0

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.


Viewing all articles
Browse latest Browse all 99410

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>