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;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…