You were getting NullpointerException because you are declaring another ChromeDriver instance inside the initialize() method and creating an instance of ChromeDriver object whose scope is limited to initialize() method itself.

Make the following corrections in the code:

In Base class:

public void initialize() {
 ..some code

   = new ChromeDriver() ;

..some code 

And you don’t need another WebDriver driver declaration in Front class.( you can remove it).

In Front class:

public class Front extends Base {

  public void Login() throws InterruptedException {
      Pages PagesObj = new Pages(driver);

So, now the driver gets initialized in initialize() method of Base class and the same driver instance is passed through to your Page object.

Source link


Please enter your comment!
Please enter your name here