Thursday, January 17, 2019

All are used to mark a field in a page object.
@FindBy: It is 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. (api link)
Example:
    For example, these two annotations point to the same element:
    Syntax 1:        @FindBy(id = "foobar")
                              WebElement foobar;
                              @FindBy(how = How.ID, using = "foobar")  // How is an enum, ID is an Enum constant
                              WebElement foobar;
and these two annotations point to the same list of elements:
    Syntax 2:          @FindBy(tagName = "a")
                               List<WebElement> links;
                               @FindBy(how = How.TAG_NAME, using = "a")
                               List<WebElement> links;
Note: Alternative way of @FindBys: driver.findElements(new ByChained(by1,by2)); (where by1 -> By by1=By.id("");, by2 -> By by2=By.id("");)
@FindBys: Find for all DOM elements that matches each of the locators in sequence.(api link)
Example:
        @FindBys({@FindBy(id = "foo"),
              @FindBy(className = "bar")})
         private List<WebElement> list;
@FindAll: Search for all elements that match any of the FindBy criteria. (api link)
Example:
        @FindAll({@FindBy(id = "foo"),
              @FindBy(className = "bar")})
private List<WebElement> list;

@CacheLookup: as the name suggests helps us control when to cache a WebElement and when not to. This annotation when applied over a WebElement instructs Selenium to keep a cache of the WebElement instead of searching for the WebElement every time from the WebPage. This helps us save a lot of time. (api link)
Example:
        @CacheLookup
@FindBy(how=How.ID, using="foo")
private WebElement element;

Hope this Helps!!!

Related Posts:

  • Reverse Each Word in a String Input "hello world java"  1) Reverse each word in a string Input: hello world java     //Output: olleh dlrow avaj String str="hello world java"; String[] tokens=str.split(" "); for(int i=0;i<tokens.length;i++) { for(int j=… Read More
  • Manual Testing QuestionsWhat is Smoke Testing?Smoke Testing: This is build acceptance Testing performed after build is released to the Testing. This Testing is done to check the major functionalities are working fine or not.What is Sanity Testing?Sa… Read More
  • Java Program to Insert array2 into array1 at given position Java Program: Take 2 arrays, write a method to - Insert array2 in to array1 at given position//Output: {12, 13,14,5,6,15}package qasign;import java.util.ArrayList;import java.util.Arrays;public class SampleTest { public… Read More
  • Type Casting Type Casting: The process of converting value of one Datatype to another Datatype. Two ways of Casting: Widening:  Converting a smaller datatype to higher datatype is called widening. byte-> short -> char … Read More
  • Write a Java Program to Add Map Elements and Print  package qasignpackage;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;import java.util.Map.Entry;public class SampleTest {    public … Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts