С @FindBy проблема решилась следующим образом:
@Test
public void searchTest() {
open("baseUrl");
onMainPage().switchToFooFrame().getFooInput().sendKeys("123425");
onMainPage().switchToFooFrame().getFooButton().click();
}
private MainPage onMainPage() {
return new MainPage(WebDriverRunner.getWebDriver());
}
public class MainPage {
private final WebDriver driver;
@FindBy(id = "fooFrame") //фрейм
private FooFrame fooFrame;
@FindBy(id = "header")
private Header header;
public WebDriver getWebDriver() {
return driver;
}
public Header getHeader() {
return header;
}
public FooFrame getFooFrame() {
return fooFrame;
}
public MainPage(WebDriver driver) {
this.driver = driver;
getWebDriver().switchTo().defaultContent();
SelenidePageFactory.initElements(new SelenideFieldDecorator(getWebDriver()), this);
}
public FooFrame switchToFooFrame() {
getWebDriver().switchTo().frame(getFooFrame().getSelf());
FooFrame frame = new FooFrame();
SelenidePageFactory.initElements(new SelenideFieldDecorator(getWebDriver()), frame);
return frame;
}
public class FooFrame extends ElementsContainer {
@FindBy(id = "otherFrame") //фрейм
private OtherForm otherForm;
@FindBy(id = "fooInput")
private SelenideElement fooInput;
@FindBy(id = "fooButton")
private SelenideElement fooButton;