I\'m trying to write a page object in Selenium Webdriver using the page factory @FindBy
annotations. The page object is for a sidebar, and the parent WebElement
No, it is not possible this way. But you can use getter methods instead of annotation-based initialization:
public class SomePage {
@FindBy (xpath = "//div[contains(@class,'yui3-accordion-panel-content') and child::div[.='Sidebar']]")
private WebElement sidebar;
private WebElement getSomeChildElement() {
return siderbar.findElement(By.id("somechild"));
}
}