Hi there,
If I define the WebElementFacade on PageObject class as following. The WebElementFacade will be initialized and work.
@FindBy(linkText = "About us")
WebElementFacade aboutUs;
public void navigateToSubMenu(String submenu) {
this.shouldBeVisible(aboutUs);
aboutUs.click();
}
}
If I defined the WebElementFacade on PageObject class in HashMap. The WebElementFacade object will return null. May I know how to initialize the WebElementFacade before put it into HashMap or where I should call PageFactory.initElements(getDriver(), this) ? Thanks
HashMap<String, WebElementFacade> hmap = new HashMap<String, WebElementFacade>();
@FindBy(linkText = "About us")
WebElementFacade aboutUs;
public void navigateToSubMenu(String submenu) {
setHash();
getHash(submenu).click();
}
}
public void setHash() {
hmap.put("About us", aboutUs);
}
public WebElementFacade getHash(String submenue) {
WebElementFacade wf = hmap.get(submenue);
return wf;
}