Join 500+ Software Testing professionals. Solve problem and get your problem solved. Register Now!

0
Java null pointer exception

Solved 1 Answers 78 Views Selenium
0 1

I am new to Selenium WebDriver. I wrote the following piece of code using selenium/testNg and get a Java null pointer exception.

 

package in.bookscape;

import java.util.concurrent.TimeUnit;

import org.junit.After;

import org.junit.Before;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.testng.annotations.Test;

public class bookscape_langauge {

private WebDriver driver;

@Before

public void beforeTest()

{

driver = new FirefoxDriver();

}

@Test

public void test() throws InterruptedException{

driver.get("http://www.bookscape.in/");

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

}

@After

public void afterTest()

{

driver.close();

driver.quit();

}

}

The error is pointing to the get sentence in the above code.

1 Answer

0
Best answer
0
Please import jUnit @Test annotation.

Replace

 import org.testng.annotations.Test;

with

 import org.junit.Test;

It should work.
answered by
selected by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
...