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:

  • Difference between Selenium 1, Selenium 2 and Selenium 3 Selenium 1 = Selenium Remote Control Selenium 2 = Selenium Webdriver, which combines elements of Selenium 1 and Webdriver. Selenium 3 = Selenium  1 + Selenium 2 (RC is deprecated and moved to legacy package) … Read More
  • Introduction to Java What is java? Java is a programming language and a computing platform for application development. It was first released by Sun Microsystem in 1995 and later acquired by Oracle Corporation in 2010. In 2006 Sun started … Read More
  • Introduction to Software Testing What is Software Testing: Software Testing is a process of verifying or validating an application with the intention of finding bugs or defects. This can be done through either manually or using automation tool.… Read More
  • Introduction to Test Automation What is Test Automation: Test Automation or Automation Testing is a method of automating execution of tests and then  compares actual test results with predicted or expected results using special softwar… Read More
  • Selenium Introduction What is Selenium: Selenium is an Automation Testing Framework which automates web applications for testing purposes. It is an open source and mainly used for automating functional tests and regression tests. Note: It can b… 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