Annotation Interface Parent


@Target(FIELD) @Retention(RUNTIME) public @interface Parent
Mark a field whose class declaration is annotated with one of Selenium's Find... annotation, with this annotation to inject the parent container. Parent container in this case means parent in the HTML DOM. It doesn't matter if the parent is a direct parent or is any element that is upper in the DOM relative to the current element. What element the parent represents depends on the Find... annotation applied on the parent component or page class.

Examples

For an HTML snippet like
  <div id="homepage">
      <div class="component">
          <div class="sub-component">
              ...
          </div>
      </div>
 </div>
 
there can be a custom component for the div.component element:
 @FindBy(className = "component")
 public class Component extends FluentWebElement {
      @Parent
      public Homepage homepage;
      ...
 }
 
for which a sub-component can include it as a parent component:
 @FindBy(className = "sub-component")
 public class SubComponent extends FluentWebElement {
      @Parent
      public Component parent;
      ...
 }
 
Similarly a parent can be created for Component in the form of a page:
 @FindBy(id = "homepage")
 public class Homepage extends FluentPage {
      ...
 }
 
This structure can be achieved with any page-component/component-page relationship using custom FluentPage and FluentWebElement implementations.