Base class:
public class Base {
public WebDriver driver ;
@BeforeMethod
public void initialize() {
System.setProperty("webdriver.chrome.driver", "/Users/apple/eclipse-workspace/Selenium/src/Google/chromedriver");
ChromeDriver driver = new ChromeDriver() ;
driver.manage().window().maximize();
driver.get("https://google.com");
}
@AfterMethod
public void exitdriver() {
driver.close();
}
}
Page Class:
public class Pages {
WebDriver driver ;
public Pages( WebDriver driver)
{
this.driver = driver ;
}
@FindBy(how = How.XPATH, using = ".//*[@id='lst-ib']")
WebElement search ;
public void Googletext() throws InterruptedException
{
search.sendKeys("Test");
}
}
Main Class
public class Front extends Base {
@Test
public void Login() throws InterruptedException {
Pages PagesObj = new Pages(driver);
PagesObj.Googletext();
}
}
driver
are you sending as a parameter for the Pages Constructor?