Make WebDriver
instance public and there is no need to create it's reference again in openBrowser()
method. Use following code:
public class HomePageTest {
public WebDriver driver; //driver instance is public
@BeforeMethod
public void openBrowser(){
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.get("URL to open");
}
@Test
public void testTitle(){
HomePage page = new HomePage(driver);
Assert.assertEquals("actualTitle", driver.getTitle());
}
}