-2

/* 1538254052650 Marionette DEBUG [6442450945] Received DOM event pageshow for http://www.demo.guru99.com/v4/index.php Exception in thread "main" java.lang.NullPointerException*/

public static void setUp() throws Exception {

System.setProperty("webdriver.gecko.driver","D:\\\\Selenium\\\\New\\\\Driver('s)\\\\geckodriver.exe");

File pathBinary = new File("C:\\Program Files\\Mozilla Firefox\\firefox.exe");

FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);  

DesiredCapabilities desired = DesiredCapabilities.firefox();

FirefoxOptions options = new FirefoxOptions();

desired.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options.setBinary(firefoxBinary));

WebDriver driver = new FirefoxDriver(options);

driver.navigate().to("http://www.demo.guru99.com/v4/index.php");

driver.manage().window().maximize();

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

}

public static void main(String args[]) throws Exception {

    setUp();

    driver.findElement(By.name("uid")).sendKeys("mngr152686");

    driver.findElement(By.name("password")).sendKeys("YgabAzy");

    driver.findElement(By.name("btnLogin")).click();

    Thread.sleep(3000);

   System.out.println("Login Succsful");


}

1 Answers1

0

Try passing values by xpath. Sometimes helps solve the null pointer exceptions when a particular element is missing on the webpage.