I would like to use a static variable from a sub-class in a super-class static method. It seems that I'm not able to ensure that variable is present, since it is static and I cannot enforce static members in this way.
Utimately, I'd like to do similar in functionality to this:
protected class Page {
WebDriver driver = new ChromeWebDriver();
public static boolean onPage () {
return driver.findElements(By.id(PAGE_NAME)) != null;
}
}
public class HomePage extends Page {
static String PAGE_NAME = "home";
}
public class LoginPage extends Page {
static String PAGE_NAME = "login";
}
...
HomePage.onPage();
...
What is the best pattern for something like this?
Note: The primary requirements are:
- onPage() remain static and
- onPage() takes no parameters
Aucun commentaire:
Enregistrer un commentaire