Instead of downloading and using your own Selenium jars I would use Maven. Maven is used as a build tool and will download any dependencies you might need, like the latest version of Selenium.
Steps:
Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install jUnitJUnit with the installer)
Install Firefox
Create a new project: Maven -> Java Application
Under project files edit pom.xml and add Selenium dependency
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.45.0</version>
</dependency>
</dependencies>
Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.
Pasted the following code at the bottom ofto replace the newJUnit test class file
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class NewEmptyJUnitTest {
@Test
public void hello() {
WebDriver driver = new FirefoxDriver();
driver.get("http://sqa.stackexchange.com/questions/13213/how-to-configure-selenium-webdriver-with-netbeans");
WebElement acceptAnswerLink = driver.findElement(By.id("vote-accepted-13214"));
acceptAnswerLink.click();
driver.quit();
}
}
- Hit Ctrl-F6 to run the unit-tests
The result should be that Firefox starts opening this page and accepting this answer ;-)
Put the files on github: https://github.com/nreijmersdal/NetbeansMavenSelenium