Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
241 views
in Selenium by
recategorized by

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 like 0 dislike
by
selected by
 
Best answer
Please import jUnit @Test annotation.

Replace

 import org.testng.annotations.Test;

with

 import org.junit.Test;

It should work.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...