lang.nullpointerexception while running the below code.
package aditi;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
public class TestNG {
public static WebDriver driverok ;
@Test
public void main(){
driverok.findElement(By.id("email")).sendKeys("[email protected]");
driverok.findElement(By.id("pass")).sendKeys("Aasds");
driverok.findElement(By.id("u_0_2")).click();
System.out.println("login successfully");
}
@BeforeMethod
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver", "E:\\selenium\\chromedriver.exe\\");
WebDriver driverok = new ChromeDriver();
driverok.get("https://www.facebook.com/");
driverok.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
@AfterMethod
public void afterMethod() {
driverok.quit();
}
}