Skip to content

iOSFindBy & AndroidFindBy annotations are ignored #211

Description

@justintilson

I've been trying for a couple of days to get iOSFindBy & AndroidFindBy annotations working with page objects and the PageFactory. I've tried versions 2.2.0 and 3.0.0 of the java-client and tests for Android and iOS, all with the same result - which is the same as not including any annotations.

Here is a truncated version of one of my page objects

publicclassHomePhonePageextendsBaseHomePage {
publicHomePhonePage(AppiumDriverdriver) {
super(driver);
PageFactory.initElements(newAppiumFieldDecorator(driver,
IMPLICIT_WAIT,
TimeUnit.SECONDS),
this
);
}
@iOSFindBy(accessibility = "home_landing_my_favorites_count_label")
privateWebElementmyFavoritesCountLabel;
publicStringgetMyFavoritesCountLabel() {
returnmyFavoritesCountLabel.getText();
}
}

My test code:

@TestpublicvoidtestHomeIsValid() {
homePhonePage = newHomePhonePage(driver);
globalNavPage = newGlobalNavigationPage(driver);
homePhonePage.clickHamburgerMenu(); //FAILS HERE because element was not foundglobalNavPage.clickHome();
}

When I debug into PageFactory.initElements, I see [unknown locator] for each property that is a WebElement. Then the PageFactory defaults to looking for each page object's property name as the id or name of the WebElement and fails to find anything.

unknown-locator2

I suspect "I'm doing it wrong" but I can't figure out where. It is behaving as if the annotations are not even there.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions