@Page @InFrame(index = 0) private PageObject page; @FindBy(id = "foo-bar") @InFrame(nameOrId = "second") private PageFragment myFragment; @FindBy(tagName = "div") @InFrame(index = 1) private WebElement plainWebElement;
To facilitate the tedious process of switching to and from a particular frame/iframe; you can now just use the @InFrame annotation to specify in which frame the element should be located. The details are handled by Graphene.
@Page @InFrame(index = 0) private PageObject page; @FindBy(id = "foo-bar") @InFrame(nameOrId = "second") private PageFragment myFragment; @FindBy(tagName = "div") @InFrame(index = 1) private WebElement plainWebElement;
You can determine the iframe/frame by its index (zero based), or by nameOrId strategy. Graphene will automatically switch to a particular iframe/frame when a method is invoked on such annotated field.
When using @InFrame together with Page Object, all elements declared in such Page Object will be treated as they are annotated with the same @InFrame.