I'm trying to convert my selenium tests to use the Page Object Model (and, by extension, @FindBy). I have several object definitions like this:
public WebElement objectParent() {
return driver.findElement(By.name("parent-id")) ;
}
public WebElement objectChild() {
WebElement elem = objectParent();
return elem.findElement(By.name("child-id")) ;
}
Converting the parent object to using @FindBy
is easy:
@FindBy(name = "parent-id")
WebElement parentObj;
Basically, I want to do something like this, if possible (I know this isn't real code, this is just a pseudo example:
@FindBy(name = "parent-id")
WebElement parentObj;
@FindBy(parentObj.name = "child-id")
WebElement childObj;
But is there a way too target the child element within the parent element using @FindBy?
. I need to do it this way because I am targeting specific elements on the page that may share the same name or class name with other elements on the page. Thanks!