Skip to content

05. How to read from property file to Page Factory

Hemanth Sridhar edited this page Dec 13, 2021 · 1 revision

If we have a Property file for example

password_id=pass
user_name_id=email
loginButton_css=button[name='login']
allTextboxes_xpath=//input[@type='text']
something1_xpath=bla
@FilePath(value = PageObjectsConfig.ERROR_MSG_PAGE)
public class ErrorPopupPage extends PageInitializer {

@SearchBy
private WebElement password;

@SearchBy(nameOfTheLocator="user_name")
private WebElement userName;

}
  • The @FilePath value must be the path to the json
  • The nameOfTheLocator value is optional. By default, the variable name is picked up.