Im using Cucumber BDD framework with Selenium+Java. Now, I have made on BaseClass.Java in which i declare on public static WebDriver driver;
Now, in my .feature file i have many scenarios and in each scenario's steps: Given, when, then - i need to initialize the PageFactory.initElements(driver, class) again as if i dont do, then i get nullpointer expection.
Now, instead of creating object of each PageObject class and then passing main driver instance in it's constructor, im extending all PO classes and STep definition class the BaseClass.java. Now, these directly have the driver instance inherited.
There is no need to create object of any class and its working fine as only 1 driver session is maintained throughout my test.
So, none of my class has its own local WebDriver driver; instance as its using the driver , that it inherited by default from the base class.
Is it ok to use such design pattern?