June 2018
Beginner to intermediate
376 pages
8h 58m
English
The PageFactory class is quite useful, but after you have used it a while, you will find that it raises certain questions, and has some limitations. One of the first questions that is usually asked is "How do I get the locator out of the @FindBy annotation so that I can use in WebDriverWait objects?" You could write a method that takes WebElement and converts it into a string, and then try to work out what the various components are. This will not be reliable though, as things will change and the .toString() representation of a WebElement is not set in stone.
We could try populating the @FindBy annotations with variables like this:
private static final String USERNAME_LOCATOR = "username"; @FindBy(how ...
Read now
Unlock full access