Search code examples
appium-androidregression-testingfindby

AndroidFindBy ID or XPATH


Wondering if this is possible. We have our RC that has no ID for an XML layout element. In our Develop branch we add ID to the layout but haven't pulled it in yet. For AndroidFindBycan I use XPATH for RC and ID for Develop?

@AndroidFindBy(id = "fab_menu_button", xpath = "SomeXpathlocationForRC")
private MobileElement fabButton;

*** Update, this above does not work on RC build as ID is missing is there some way to have it OR this condition? by id or by xpath?


Solution

  • I did find the answer to this so others who need the answer can see. In our RC we have use the XPATH but in our DEV code we added the ID. This way it works on both apks.

    @AndroidFindAll({
            @AndroidBy(id = "fab_menu_button"),
            @AndroidBy(xpath = "//android.widget.TextView[@text='Create']")
    })
    private MobileElement fabButton;