Skip to main content
added 174 characters in body
Source Link

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:

  1. Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install jUnitJUnit with the installer)

  2. Install Firefox

  3. Create a new project: Maven -> Java Application

  4. 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>
  1. Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.

  2. 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();
  }
}
  1. 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

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:

  1. Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install jUnit with the installer)

  2. Install Firefox

  3. Create a new project: Maven -> Java Application

  4. 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>
  1. Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.

  2. Pasted the following code at the bottom of the new 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();
  }
}
  1. Hit Ctrl-F6 to run the unit-tests

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:

  1. Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install JUnit with the installer)

  2. Install Firefox

  3. Create a new project: Maven -> Java Application

  4. 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>
  1. Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.

  2. Pasted the following code to replace the JUnit test 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();
  }
}
  1. 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

added 877 characters in body
Source Link

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:

  1. Create Maven Java applicationDownload & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install jUnit with the installer)

  2. Add in Selenium dependecy in the pom.xmlInstall Firefox

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
    </dependency>
    
  3. Create a new project: Maven -> Java Application

  4. Start writing your testsUnder project files edit pom.xml and add Selenium dependency

Blog post about getting using Maven and selenium with Netbeans: http://seleniumstuff.blogspot.de/2013/08/getting-started-with-selenium-maven.html

<dependencies>
  <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.45.0</version>
  </dependency>
</dependencies>

For creating and running tests use jUnit, have a look at this example: http://testingbot.com/support/getting-started/junit.html Just ignore the Eclipse setup. Use the code :)

  1. Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.

  2. Pasted the following code at the bottom of the new 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();
  }
}
  1. Hit Ctrl-F6 to run the unit-tests

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

  1. Create Maven Java application

  2. Add in Selenium dependecy in the pom.xml

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
    </dependency>
    
  3. Start writing your tests

Blog post about getting using Maven and selenium with Netbeans: http://seleniumstuff.blogspot.de/2013/08/getting-started-with-selenium-maven.html

For creating and running tests use jUnit, have a look at this example: http://testingbot.com/support/getting-started/junit.html Just ignore the Eclipse setup. Use the code :)

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:

  1. Download & Install Netbeans with JDK at http://www.oracle.com/technetwork/java/javase/downloads/index.html (Also install jUnit with the installer)

  2. Install Firefox

  3. Create a new project: Maven -> Java Application

  4. 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>
  1. Right click project-name to get a menu and select: New -> Other. Pick the JUnit Test from the Unit Tests category. Next -> Finish.

  2. Pasted the following code at the bottom of the new 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();
  }
}
  1. Hit Ctrl-F6 to run the unit-tests
Source Link

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

  1. Create Maven Java application

  2. Add in Selenium dependecy in the pom.xml

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
    </dependency>
    
  3. Start writing your tests

Blog post about getting using Maven and selenium with Netbeans: http://seleniumstuff.blogspot.de/2013/08/getting-started-with-selenium-maven.html

For creating and running tests use jUnit, have a look at this example: http://testingbot.com/support/getting-started/junit.html Just ignore the Eclipse setup. Use the code :)