What is CacheLookup annotation in PageFactory

0 votes
What is @CacheLookup annotation in PageFactory?
Jul 5, 2019 in Selenium by Abhay
3,093 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, 2019 by Abha
• 28,060 points

Related Questions In Selenium

0 votes
1 answer

What is the use of @listener annotation in TestNG?

 @listeners are used to configure reports and ...READ MORE

answered Jan 2, 2019 in Selenium by Shuvodip
1,663 views
0 votes
2 answers

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

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

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
1,349 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,710 points
5,663 views
0 votes
2 answers

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

some of the controls not have id ...READ MORE

answered Sep 4, 2020 in Selenium by Sri
• 3,190 points
912 views
0 votes
2 answers

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,500 points
6,227 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
6,584 views
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,890 points
4,213 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
5,214 views
0 votes
1 answer

What is PageFactory in Selenium?

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

answered May 13, 2019 in Selenium by Abha
• 28,060 points
275 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, 2019 in Selenium by anonymous
• 28,060 points
729 views