Setting Up a Eclipse Project With Selenium

1. Open Eclipse

2. Click on File > New > Java Project > Enter a project name e.g. SeleniumProj

3. Click Next

4. Click on Libraries tab and click on Add External JARs

5. Add the JARs from the WebDriver client library folder and the JARs from the libs subdirectory. Click Finish

6. Right click on the project folder and select New > Class

7. Enter a Package and Class Name and then click Finish

8. Enter you first Selenium WebDriver code to navigate to a web page in Firefox

package net.brav3.webdriver.chapter1;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class NavigateToAUrl {
	public static void main(String[] args) {
		WebDriver driver = new FirefoxDriver();
		driver.get("https://developer.mozilla.org");
	}
}

Note: If you get an error that Firefox crashed, make sure to check the Selenium issues on Github. There may already be a solution either involving updating to the latest Firefox, Selenium WebDriver, or the Marionette WebDriver from Mozilla.

Leave a Comment





This site uses Akismet to reduce spam. Learn how your comment data is processed.