June 2018
Beginner to intermediate
376 pages
8h 58m
English
For the PageFactory annotation to work, you must initialize your class. WebElement objects will not be proxied and the annotations that you have specified will not be applied if you forget to do this. Initializing your class is one very simple line of code:
PageFactory.initElements(DriverBase.getDriver(), LoginPage.class);
While this is easy, it is also quite ugly and not instantly obvious to people who don't know about the PageFactory class. Let's make this easier and more understandable for any developers who are going to look at our code. What we are going to do is initialize our class in the constructor of our page object:
package com.masteringselenium.page_factory_objects;import org.openqa.selenium.WebDriver ...
Read now
Unlock full access