[Solved] How to pass the same driver instance in page Object model?


I can see you are declaring a new instance of WebDriver inside the @BeforeTest method. You need to use the WebDriver instance that you declared outside the @BeforeTest i.e. you have already declared

 static WebDriver driver;

Use the same driver inside your @BeforeTest. So inside the before method, instead of doing WebDriver driver = new FirefoxDriver(); write like driver = new FirefoxDriver();

Do same for other browser types (ie, safari, chrome).

And for you page object classes, you can do something as follows:

public class TaxPage {

    public static WebDriver driver;

    public TaxPage(WebDriver driver) {
        this.driver = driver;
    }

}

2

solved How to pass the same driver instance in page Object model?