Setup Selenium in Eclipse Galileo

Automate your testing with Selenium. Set it up in eclipse by following the following steps.

NOTE: This is for setting up selenium 2.5 Java.

1) Download Selenium HERE (or, and search for Java)

2) start eclipse, and install testNG, testNG is like a beefed version of JUnit, and can be ran via ant ( so can JUnit, but I think testNG comes with some additional things that junit doesnt ) See this comparison

2.1) Install TestNG, in eclipse (on mac) go to Help > Install New Software > use the address:

2.2) Select TestNG and complete the install of the plugin and restart.

3) after restart, select File > new > Java Project.

3.1) create a libs folder in the project

3.2) extract the selenium zip file jars into the libs folder (even the ones that are in the libs folder inside the extracted folder, you can just put them straight into your new libs folder)

3.3) right click your project > properties > java build path > add jars > select the libs folder in your project and highlight all the jars and add them, click ok and be done with that.

4) After project is created > Right click “src” create a folder called “tests” (this name is not important, its just a folder name)

5) right click on the new “tests” folder and click New > Other > When window comes up filter and search for “TestNG” > select “TestNG class” > and create the class, When the next window comes up choose the Source folder by clicking “browse” > select your project > then its src folder. Click browse next to the package, and select the folder you just created called “tests”.

6) when the class comes up, i usually rename the function to “main” instead of “f”.

7) paste code

package tests;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;



import org.testng.annotations.Test;

public class NewTest {


public void main() {

WebDriver driver = new FirefoxDriver();


WebElement searchBox = driver.findElement("gbqfq"));

if( searchBox != null ) {

System.out.println("found search box...");


//wait for google to asynchronously return.

WebDriverWait wait = new WebDriverWait(driver, 3);

// Wait for search to complete

wait.until(new ExpectedCondition() {

public Boolean apply(WebDriver webDriver) {

System.out.println("finding speedtest ...");

return webDriver.findElement(By.partialLinkText(" - The Global Broadband Speed Test")) != null;






8) right click project > TestNG > Convert to TestNG

9) right click project > run as TestNG Test

this should pass and launch firefox and type into the search and verify the link shows up.

Leave a comment