PopperFramework Wiki
Declarative PageObject description
Status: Beta
Brought to you by:
michaelbulla
Sometimes you run into the problem to debug your page-object because it doesn't find some element on your page until you realize that your pages didn't open the page you expect to be and therefor the element couldn't be found.
For that case PopperFramework supports checkinig to be on the right page when getting elements
:::java
@Page(application="Popper Test", name="Verify Page")
@VerifyBy(title="Title verified")
public interface VerifyPagePO {
@PageAccessor(uri="/pages/titlePage.html")
void open();
@Locator(name="Message", id="message")
ILabel message();
}
:::java
@Page(name="Site divided in PageObjects")
public interface Testsite {
@PageAccessor(uri="Testseite.html")
void open();
@Locator(name="Header")
@LocateById("header")
Header header();
@Locator(name="Footer")
@LocateById("footer")
Footer footer();
}
public interface Header {
@Locator(name="Homepage")
@LocateById("homepageLink")
ILink homepageLink();
@Locator(name="Logout")
@LocateById("logoutLink")
ILink logoutLink();
}
public interface Footer {
@Locator(name="Company")
@LocateById("companyLink")
ILink companyLink();
}
Say you have a Website with a table like

:::java
@Page(application="Popper Test", name="Self Implemented Locator")
public interface TablePO {
@PageAccessor(uri="/pages/table.html")
void open();
// using tr[.//td] to exclude headers (using th instead of td)
@Locator(name="all users as list", xpath="//table[@id='users']//tbody/tr[.//td]")
List<User> allUsers();
@Locator(name="all forenames", xpath="//table[@id='users']//tr/td[@class='firstname']")
List<ILabel> allForenames();
@Locator(name="all users as set", xpath="//table[@id='users']//tbody/tr[.//td]")
Set<User> allUsersAsSet();
@Locator(name="all users as array", xpath="//table[@id='users']//tbody/tr[.//td]")
User[] allUsersAsArray();
@Locator(name="element count", xpath="//table[@id='users']//tbody/tr[.//td]")
int elementCount();
@Locator(name="all users", xpath="//table[@id='users']//tr[@id={0}]")
User userById(String id);
public static interface User {
@Locator(name="Firstname", cssSelector=".firstname")
ILabel firstname();
@Locator(name="Lastname", cssSelector=".lastname")
ILabel lastname();
@Locator(name="Birthdate", cssSelector=".birthdate")
ILabel birthdate();
}
}
You may count elements on your page, too. Just use as the return type of a method an int, short or long, than you will get the number of that elements on you page instead of the elements itself.