I am working on a Selenium + java project where all Web Element in a class are declared as -
public class CheckoutPaymentConfirmpage extends WebPage{ public final Button btnPrintorder = new Button("//input[@id='but_Print']"); public final TextField txtpassword = new TextField("password", "//input[@id='pass']"); // Some more elements here // Some page object methods here } Now when ever test need to access these elements they are directly invoked over the object of CheckoutPaymentConfirmpage class What ever little java (or OOPS) I know, has taught me that members should be as hidden as possible. Hence I would have had btnPrintorder and txtpassword declared private and would access them using getters or would have created methods in page object class to be used by tests.
But when I convey this to others they don't see much value in it as state of instance variable (i.e. btnPrintorder etc) would not be changed from one object to another for page object class (i.e. CheckoutPaymentConfirmpage etc)
Hence in this situation, is it ok to leave instance variable as public?