I wonder if it is good practice to use a private static final for web elements, and then issue a getter for this web element
example LoginPage:
private static final SelenideElement LOGIN_BUTTON = $(By.xpath("XPath"));
And getter for loginButton...
So is this a good practice?
CodePudding user response:
You won't get any advantages, using static for element fields.
If you look for examples and tutorials, you won't meet such implementations.
This is POM approach recommend by Selenide:
https://selenide.gitbooks.io/user-guide/content/en/pageobjects.html
You might think about making everything static, not only element fields. Someone likes such kind of stateless implementation, but I believe it's used by a few people and not really popular. There is no articles like "Guys, use static POM, it's much better".
CodePudding user response:
No, it's not a good practice to follow in the case of locators, and also as you mentioned you use POM so it's important to make them public and move to base locator class if same locator is needed on multiple pages.
