I was going through an Automation Framework that follows Page Object Model but is a bit unstructured. It grew over the period of time and now has around hundred of tests running. While running through the framework, I noticed that some QA had followed writing the webpage locators in the properties file and other in the pageobjects itself. So I was wondering,
How the performance of the tests will vary in bigger test suites(say 1000s of test) if webpage locators follow the different declaration in Java as below:
1. In Properties file(s)
Storing the locator using the properties file and then referencing them.
loginBtn=login
driver.findElement(By.id(prop.getProperty("loginBtn"))).click();
2. In seperate Locator class(es)
Storing the locator using a dedicated locator class and referencing them.
By loginBtn = By.id("login");
driver.findElement(locators.loginBtn).click();
3. In PageObject class
Storing the locator using pageobjects classes itself and create a By object for every element.
driver.findElement(loginBtn).click();
4. In Page Factory
Storing the locator using page factory and initializing it.
@FindBy(id="login")
WebElement loginBtn;
I would appreciate if someone can provide a detailed performance analysis of these strategies and in what situation can we prefer the either of the above strategy.