1

How do we implement LoadableComponent when we have a fluent api, lets create a basic set of classes, shown below:

public class LoginPage {

    // @FindBy locators

    public DashboardPage login(String user, String pass) {
    // something
    }
}

public class DashboardPage {

    //  @FindBy locators

    public UsersPage navigateToUsersPage() {
     //navigate to users page
    }
}

Now, we have a test maybe something like this:

@Test
public void coolTest() {
 loginPage.open().login("foo", "bar").navigateToUsersPage();
 //assert something
}

Where does loadable component come into play here? How can we ensure the page(s) are loaded when they should be etc? We aren't explicitly calling open on 2 of the 3 pages used here.

Thank you

0
0

LoadableComponent is just an abstract class that leaves the implementation of what you consider "the page is loaded" to yourself.

Where does loadable component come into play here?

That depends on what page you'd like to check for being loaded. See the link below in my answer. You, basically, should apply the pattern to the particular page.

Like this:

public class LoginPage extends LoadableComponent<LoginPage> {

    // @FindBy locators

    public DashboardPage login(String user, String pass) {
       // something
       return new DashboardPage().get();
    }

   // TODO: !!! - Implement isLoaded() and load() methods - !!!

}

public class DashboardPage extends LoadableComponent<DashboardPage> {

    //  @FindBy locators

    public UsersPage navigateToUsersPage() {
        return new UsersPage().get() // !!! - This call requires UsersPage is also extending LoadableComponent
    }

   // TODO: !!! - Implement isLoaded() and load() methods - !!!

}

how can we ensure the page(s) are loaded

LoadableComponent pattern will not answer you how to ensure the page is loaded. It just prescribes you to implement the method where you will code the logic for your particular case and your particular pages.

For example you might implement that method in the way it awaits for certain conditions against certain page elements.

There is a good post regarding the topic here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.