Reputation: 85
I am stuck at a situation.
Here i have created one testsuite with two test cases in it.
First test case is executed properly. In second test case, it throws error of java.lang.NullPointerException
at Webdriver driver
Test Case:
public class second{
private WebDriver driver;
@Test
public void sample() throws Exception
{
System.out.println("tab bar");
driver.findElement(By.id("tabs"));
//My code
}
}
Upvotes: 0
Views: 1065
Reputation: 1224
WebDriver is an interface and cannot be initialized, you should use the implementation like: WebDriver driver = new FirefoxDriver();
Upvotes: 0
Reputation: 12523
WebDriver driver;
is not initiated. What do you expect? The exception is absolutly correct. You can try the following code to avoid the exception:
driver= new WebDriver();
driver.findElement(By.id("tabs"));
Upvotes: 1