selenium-webdriver Using @FindBy annotations in Java

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


  • CLASS_NAME: @FindBy(className = "classname")
  • CSS: @FindBy(css = "css")
  • ID: @FindBy(id = "id")
  • ID_OR_NAME: @FindBy(how = How.ID_OR_NAME, using ="idOrName")
  • LINK_TEXT: @FindBy(linkText= "text")
  • NAME: @FindBy(name= "name")
  • PARTIAL_LINK_TEXT: @FindBy(partialLinkText= "text")
  • TAG_NAME: @FindBy(tagName="tagname")
  • XPATH: @FindBy(xpath="xpath")


Note that there are two ways of using the annotation. Examples:

@FindBy(id = "id")


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

are equal and both look for element by its ID. In case of ID_OR_NAME you can only use

@FindBy(how = How.ID_OR_NAME, using ="idOrName")

PageFactory.initElements() must be used after page object instantiation to find elements marked with @FindBy annotation.

Got any selenium-webdriver Question?