Showing posts with label page object model. Show all posts
Showing posts with label page object model. Show all posts
Thursday, 9 May 2019
Interview | @CacheLookup - in Page Object Model | Page Factory
@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.
Syntax:
@FindBy(how = How.NAME, using = "firstname")
@CacheLookup
public WebElement firsNameCached;
Wednesday, 16 May 2018
Interview question | Page Factory | Lazy loading
Here is the interview question:
As per "Page Factory", all the elements will be initialized at the time of page load.
But in dynamic applications how page factory works?
Ex: Assure a drop down content ( options) loads on click of the respected select box, how can you implement page factory for this?, as page factory initializes elements at the time of page load only.
Answer:
Lazy load concept.
AjaxElementLocatorFactory is a lazy load concept in Page Factory pattern to identify WebElements only when they are used in any operation
i.e. a timeOut for a WebElement can be assigned to the Object page class with the help of AjaxElementLocatorFactory.
Syntax : ( similer to plain "Page Factory init elemnts" method )
PageFactory.initElements(new c(driver, 30), this);
If element not found in 30 secs, NoSuchElemementException throws.
happy coding.
As per "Page Factory", all the elements will be initialized at the time of page load.
But in dynamic applications how page factory works?
Ex: Assure a drop down content ( options) loads on click of the respected select box, how can you implement page factory for this?, as page factory initializes elements at the time of page load only.
Answer:
Lazy load concept.
AjaxElementLocatorFactory is a lazy load concept in Page Factory pattern to identify WebElements only when they are used in any operation
i.e. a timeOut for a WebElement can be assigned to the Object page class with the help of AjaxElementLocatorFactory.
Syntax : ( similer to plain "Page Factory init elemnts" method )
PageFactory.initElements(new c(driver, 30), this);
If element not found in 30 secs, NoSuchElemementException throws.
happy coding.
Subscribe to:
Posts (Atom)