Annotation Type FindBy


  • @Retention(RUNTIME)
    @Target({FIELD,TYPE})
    public @interface FindBy

    Used to mark a field on a Page Object to indicate an alternative mechanism for locating the element or a list of elements. Used in conjunction with PageFactory this allows users to quickly and easily create PageObjects.

    It can be used on a types as well, but will not be processed by default.

    You can either use this annotation by specifying both "how" and "using" or by specifying one of the location strategies (eg: "id") with an appropriate value to use. Both options will delegate down to the matching By methods in By class.

    For example, these two annotations point to the same element:

     @FindBy(id = "foobar") WebElement foobar;
     @FindBy(how = How.ID, using = "foobar") WebElement foobar;
     

    and these two annotations point to the same list of elements:

     @FindBy(tagName = "a") List<WebElement> links;
     @FindBy(how = How.TAG_NAME, using = "a") List<WebElement> links;
     
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String className  
      java.lang.String css  
      How how  
      java.lang.String id  
      java.lang.String linkText  
      java.lang.String name  
      java.lang.String partialLinkText  
      java.lang.String tagName  
      java.lang.String using  
      java.lang.String xpath  
    • Element Detail

      • how

        How how
        Default:
        org.openqa.selenium.support.How.UNSET
      • using

        java.lang.String using
        Default:
        ""
      • id

        java.lang.String id
        Default:
        ""
      • name

        java.lang.String name
        Default:
        ""
      • className

        java.lang.String className
        Default:
        ""
      • css

        java.lang.String css
        Default:
        ""
      • tagName

        java.lang.String tagName
        Default:
        ""
      • linkText

        java.lang.String linkText
        Default:
        ""
      • partialLinkText

        java.lang.String partialLinkText
        Default:
        ""
      • xpath

        java.lang.String xpath
        Default:
        ""