I have written the below code and getting the java null pointer exception. please help what is the problem.
public class testngbasics {
WebDriver driver;
@BeforeMethod
public void setbrowser() {
System.setProperty("webdriver.chrome.driver","C:\\Users\\chromedriver.exe");
WebDriver driver= new ChromeDriver();
driver.manage().timeouts().pageLoadTimeout(70, TimeUnit.SECONDS);
driver.get("http://demo.guru99.com/v4/");
driver.manage().deleteAllCookies();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(70, TimeUnit.SECONDS);
}
@Test
public void login1() {
driver.findElement(By.xpath("//input[@name='uid']")).sendKeys("mngr212595");
driver.findElement(By.xpath("//input[@name='password']")).sendKeys("EgebYpy");
driver.findElement(By.xpath("//input[@value='LOGIN']")).click();
System.out.println(driver.getTitle());
}
@AfterMethod
public void closebrowser()
{
driver.close();
}
}
I am getting the error:
java.lang.NullPointerException it is only going to @beforemethod annotation and not going to @test and @aftermethod