I need to test web page, so we build pages via enum class. In first enum class we have Pages and in second enum we have saved type of pages like "uk", "canada" it , because different type of page need to create different page
I try to user solution from these topic Can I use the builder pattern on a Java Enum
public class HomePage extends BasePage {
public String url = "/ccrz__HomePage";
public Storefront storefront;
@FindBy(how = How.XPATH, using = "//div[contains(@class, 'cc_tmpl_HomePage')]")
private WebElement mainContainer;
public HomePage(Storefront storefront) {
super(storefront);
super.setUrl(this.url);
}
@Override
public boolean validatePage() {
return isDisplayed(mainContainer);
}
public enum Pages {
HOMEPAGE(new HomePage()),
ORDER_HISTORY_PAGE(new MyAccountOrderHistoryPage()),
MY_ACCOUNT_PAGE(new MyAccountPage()),
private final BasePage page;
private final Storefront storefront;
Pages(BasePage page, Storefront storefront) {
this.page = page;
this.storefront = storefront;
}
public BasePage get() {
return this.page;
}
Ass you can see error occurs in enum class because for example 'new HomePage()' need Storefront param and I don't have any idea how to solve it...
Aucun commentaire:
Enregistrer un commentaire