Selenium 2.0 WebDriver – How to Configure Selenium Webdriver in Eclipse and execute some simple test script.

Steps to install Selenium web driver in Eclipse:

Step 1: Install Java on your computer.

Download and install the Java Software Development Kit (JDK). You download the JDK file from this location:

Note: This JDK version comes bundled with Java Runtime Environment (i.e. JRE) so we don't need to install the JRE separately.

Step 2: Install Eclipses IDE

Now download “Eclipse IDE for Java Developers”. You can download eclipses from this location:

Make sure to choose correct link for downloading eclipses which corresponds to your OS i.e. for Windows 32 Bit and 64 Bit versions.
You should be able to download a ZIP file named “”.

Inside the ZIP file, there is an “eclipse” folder which contains all the application files. So we can extract the “eclipse” folder anywhere in your PC. Let say we want to extract it to C drive.

Step 3 – Download the Selenium Java Client Driver

You can download the Selenium Java Client Driver from this location:

Click on Download link which is associated with java release. Download the jar files. You will find client drivers for other languages there, but only choose the one for Java as shown above in the screenshot.

After downloading you will get a folder which should contain two jar files related to selenium, a lib folder which also contains jar files inside it. Beside this, there is a change log file as well. Refer to the screenshot below.

Create a new folder with name say 'Selenium' in C drive and extract the jar files to 'Selenium' folder.

Step 4: Create a New project in Eclipse:

Navigate to C drive and open eclipse folder where we have extacted all the application files related to eclipse. In Eclipse folder you would find a 'eclipse.exe' file. Now click on the .exe file

This would ask you to select a workspace, you may accept the default location or simply create a new workspace inside C drive and confirm OK.

- Now in Eclipse create a new project and for creating click on File menu –> New –> Java Project -> Name the project as “testproject” and click finish.

- Create a new Java class, for doing this again click on File menu –> New -> Class then name it as “testclass” and select the checkbox for 'public static void main (String[] args) and click finish.

On clicking 'Finish' in 'Java Class' wizard, your Eclipse IDE should look like the image below.

- Now Right-click on testproject and select Properties.
- On the Properties window, click on “Java Build Path”.
- Click on the Libraries tab, and then click “Add External JARs..”
- Navigate to C:\selenium-2.37.0\ (or any other location where you saved the extracted contents of “” in step 3).
- Add all the JAR files inside and outside the “libs” folder. Your Properties window after adding all the jar file should now look similar to the image below.

- Finally, click OK and we have completed importing Selenium libraries into our project.

Step 5: Time to Code!!

Now it’s time to write some code. For this, let use the wikipedia site to create a sample script for test execution.

Example 1:

Example 2:


import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class testClass {
  private WebDriver driver;
  public void setUp() throws Exception {
    driver = new FirefoxDriver();

// Search using keyword through Google search

  public void testtestclass() throws Exception {
        //Open Home Page
        //Enter text in search box
        //Click Search button

  public void tearDown() throws Exception {

Happy testing :)

Thanks & Regards,

Pinaki Mohapatra

Quality Assurance Engineer

Mindfire Solutions

Views: 160387

Add a Comment

You need to be a member of Software Testing Club - An Online Software Testing Community to add comments!

Join Software Testing Club - An Online Software Testing Community

Comment by Madhava Verma Dantuluri on March 2, 2014 at 16:34

This is so much effort to put in so good. Good effort.

Comment by Pham Thuy on November 12, 2013 at 8:17

Thank you for sharing. Please continous...


© 2017   Created by Rosie Sherry.   Powered by

Badges  |  Report an Issue  |  Terms of Service