Saturday, 10 August 2013

How To Configure Selenium Webdriver With Java(Eclipse)

Configure Selenium Webdriver  With Java(Eclipse)

Step1:Download Java IDE  from

Step 2: Download JDK according to System Type (32-bit or 64-bit) from

Step 3: Download Selenium Webdriver for JAVA from

Step 4 : Install JDK

Step 5 : Set Environment Variables (Windows 7 )

1.Right Click On Computer
2.Click on Properties 
3.Click On ‘Advance Settings’
4.On  ‘System Properties ‘  Click On tab ‘Advance’
5.Click on ‘Environment Variables ‘

 6.Copy  following path where JDK  is installed .
C:\Program Files\Java\jdk1.6.0\bin

7.On Environment Variable Window  Click ‘New’ Under System Variable  and Set  Path: C:\Program Files\Java\jdk1.6.0\bin
-If Path Variable already Exist Then Edit it .

Copy  following Path Where JDK is installed :

On Environment Variable Window Click ‘New’ under  User Variables and Set  CLASSPATH :

Enviornment is set up now  start JAVA IDE

Step 6 : Extract Downloaded JAVA IDE  and Click on ‘Eclipse’
Set Workspace and Check Option “Use this as Default browser”

Step 7: Open File -> New-> Other

Click On ‘Next’
Click on ‘Finish’

Step 8 : Right Click on ‘Src’ and  Select New-> Package 

Give Name as Com.Project1 and Click on ‘Finish’

Step 10: Configure Build Path:
-Right Click on Src, Select Build Path->Configure Build Path

-Click on Tab ‘Library’ and Click on ‘Add External Jars’
Select  Selenium  Webdriver  Jar files .

Step 11 : Now Start Coding in Main() J
Paste below  code in Class
package com.project1;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.*;

public class Class1 {
        public static void main(String[] args) {
//Initiate Driver   
 WebDriver driver = new FirefoxDriver();
//Get Element By Id
driver.findElement("sb_form_q")).sendKeys("Test Automation");
System.out.println("Test Completed");


Step 12 : Run Test

1.Right Click on Class1
2.Select Run As ->Run Java Application

To Run  Selenium script in IE or Chrome Following changes may Require

       1. Download Driver from according to
 System Type (32 –bit or 64-bit)

2. Add  import* and import*;
For iE and Chrome respectively
3. Add following statements to give path of respective drivers .
For ie :
System.setProperty("", "C:\\Users\\IE Driver\\IEDriverServer_Win32_2.33.0\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();

For Chrome :
System.setProperty("", "C:\\Users\\Chrome Driver\\chromedriver_win32_2.1\\chromedriver.exe");
WebDriver driver = new ChromeDriver();


  1. Great Work!!

    Step by Step info..Thanks got me started :)


  2. This comment has been removed by the author.

  3. Thanks !! It is really a nice one .. easy step by step information !!

  4. great blog.......Is there any tool ,which will give xpath ?My app only supports IE.

    1. Hi Anjali,

      I know It is a big problem with applications which only works with IE ,In My knowledge there is not any tool which can help you with IE and Xpath,But using developer tool in IE ,you can develop practice of creating xpath using class names and other properties,Also you can use CSS and Id rather than Xpath.