Skip to content

iOSFindBy & AndroidFindBy annotations are ignored #211

@justintilson

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

public class HomePhonePage extends BaseHomePage {

    public HomePhonePage(AppiumDriver driver) {
        super(driver);

        PageFactory.initElements(new AppiumFieldDecorator(driver,
                        IMPLICIT_WAIT,
                        TimeUnit.SECONDS),
                this
        );
    }

    @iOSFindBy(accessibility = "home_landing_my_favorites_count_label")
    private WebElement myFavoritesCountLabel;

    public String getMyFavoritesCountLabel() {
        return myFavoritesCountLabel.getText();
    }
}

My test code:

    @Test
    public void testHomeIsValid() {

        homePhonePage = new HomePhonePage(driver);
        globalNavPage = new GlobalNavigationPage(driver);

        homePhonePage.clickHamburgerMenu(); //FAILS HERE because element was not found
        globalNavPage.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.

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