I am using Pageobjects to run my scripts. I declared two packages - one for Pageobject definition and the other for TestNGclasses. Supposed If I have 3 classes in Package-1 then I would correspondingly have 3 test classes in package-2.
As of now I have 2 classes ( Login and home) in Package-1 and test classes for the same in Package-2
I declared the driver in LoginTest.java in package-2 as follows;
public static WebDriver driver = new FirefoxDriver();
@BeforeMethod
public void Setup(){
driver.get(StringUrl);
driver.manage().window().maximize();
}
Now When I call HomeTest.java it shows Null Pointer Exception; How can I declare the webdriver once and use it's instance in multiple test classes?
public class searchPOTest {
private WebDriver driver;
public void HomePOTest(WebDriver driver){
this.driver = driver;
}
@Test(priority=1)
public void testvalidsearchnInputs() throws Exception {
//homePagePO.doaSearch("Google");
homePagePO homeTosearch = PageFactory.initElements(driver, homePagePO.class);
searchResultPO toSearch = homeTosearch.search("Google");
}