@FindBy – It is used to locate web elements using different locators strategies.
@FindBy(how = How.ID, using = “userName”)
WebElement username;
@FindBys – To locate a web element with more than one search criteria, you can use @FindBys annotation. This annotation locates the web element by using the AND condition on the search criteria.
@FindBys({
@FindBy(class=”classname”),
@FindBy(id=”idname”)
})
WebElement name;
@FindAll – The @FindAll annotation locates the web element using more than one criteria, given that at least one criteria match. Contrary to @FindBys, it uses an OR conditional relationship between the multiple @FindBy.
@FindAll({
@FindBy(id=”btn”, //doesn’t match
@FindBy(name=”submit”), //Matches
@FindBy(class=”submitclass”) //doesn’t match
})
WebElement submitButton;
@CacheLookUp – The @CacheLookUp annotation is very useful when you are referring to the same web element multiple times. Using @CacheLookUp, we can store the web elements in cache memory right after reading for the first time. It fastens our execution and the code, need not look up for the element on the web page and directly references it from memory.
The @CacheLookUp can be prefixed with any of the annotations discussed above, i.e., @FindBy, @FindBys & @FindAll.
@CacheLookUp
@FindBys({
@FindBy(class=”checkbox-class”),
@FindBy(id=”checkbox-id”)
})
WebElement chkBox;