What is @CacheLookup annotation in PageFactory?

0 votes
What is @CacheLookup annotation in PageFactory?
Jul 5 in Selenium by Abhay
86 views

1 answer to this question.

0 votes

Hey Abhay, PageFactory annotation @CacheLookup is used to mark the WebElements once located so that the same instance in the DOM can always be used. CacheLookup attribute can be used to instruct the InitElements() method to cache the element once its located and so that it will not be searched over and over again. 

It is useful when the elements that are always going to be there. For AJAX based applications, it may not work where the DOM changes based on user action on the page, otherwise every time when we use a Web Element the WebDriver will go and search it again. For example:

@FindBy(id="firstname") 

@CacheLookup 

private WebElement userName;
answered Jul 5 by Abha
• 22,870 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

What is the role of TestNG & JUnit frameworks in Selenium?

Well TestNG and JUnit are test frameworks ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
259 views
0 votes
1 answer

What is the difference between dot and text() in XPath?

Even though there is some difference between ...READ MORE

answered Apr 25, 2018 in Selenium by king_kenny
• 3,650 points
1,179 views
0 votes
1 answer

what is the need of xpath when you have attributes like id ,class,name in selenium?

It is not necessary that every element ...READ MORE

answered Jun 1, 2018 in Selenium by Vinita
• 220 points
159 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,090 points
548 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
882 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
546 views
0 votes
1 answer

What is PageFactory in Selenium?

Hi Shruti, The PageFactory class in Selenium is an extension ...READ MORE

answered May 12 in Selenium by Abha
• 22,870 points
32 views
0 votes
1 answer

What is the use of @Rule annotation in JUnit?

Hello Sarfaraz, JUnit provides special kind of handling ...READ MORE

answered Jun 19 in Selenium by anonymous
• 22,870 points
33 views