×
☰ See All Chapters

Selenium WebDriver Setup in Eclipse

There is no WebDriver software or any WebDriver application to install, but there is some prerequisite software installations needed to use selenium WebDriver. Below are two important setup should be ready to use selenium WebDriver.

  1. Install Java 8 or higher version installation. 

  2. Set path in environment variables 

  3. Eclipse setup or any Java IDE of your interest. 

After these important installations there is no much setup needed. In the next tutorial of Selenium web driver first test case example you will learn the steps to create the sample.

Step 1: Install JDK (Java Development Kit)

Download the JDK from below link and install the software in your system.

https://www.oracle.com/technetwork/java/javase/downloads/index.html

Step 2: Set path in environment variables

Why we need to set path?

When we set the path, we can compile and execute java programs by keeping java files in our desired folder structures. If path is not set, then to execute programs we have to keep java files in a folder where java compiler (javac.exe) is present. We should not disturb the java development kit installation environment by keeping our program files.

How to set path?

1. Right click on Computer (Windows 7)/ This PC (Windows 10) , select Properties

selenium-webdriver-setup-0
 

2. Click on “Advanced System Settings”

selenium-webdriver-setup-1
 

3. Click on Environment Variables

selenium-webdriver-setup-2
 

4. In System Variables double click on path variable. To the existing value append semicolon then append path of bin folder. Finally click on OK.

Variable name:  path

Variable value:    <whatever present before>;C:\Program Files\Java\jdk1.8.0_144\bin;

selenium-webdriver-setup-3
 
selenium-webdriver-setup-4
 

Once java path is set open command prompt and type “java –version”, we should see java version. If you get the error as “java is not recognized as an internal or external command, operable program or batch file” then java is not installed in your system.

selenium-webdriver-setup-5
 

Step 3: Setup Eclipse and workspace

1. Download Eclipse IDE for java from Eclipse Website. You will get it in zip file format. Unzip it to get the executable files. This software is not required to install in OS, it is like portable software. Launch eclipse by clicking on "eclipse.exe" which will be available inside the unzipped folder.

selenium-webdriver-setup-6
 

2. When eclipse is opened, it asks for a workspace folder. Give your preferred location and press "ok". This workspace folder will be used by eclipse to save all our project work.

  selenium-webdriver-setup-7
 

After eclipse is launched

 selenium-webdriver-setup-8
 

3. Close welcome window, it is better to unselect “Always show Welcome at start up” option at right bottom corner. Click on Open Perspective button and select Java option.

selenium-webdriver-setup-9
 
selenium-webdriver-setup-10
 

4. Select File -> New -> Project -> Java Project -> Next

Enter the project name; our project name is “HelloWorldDemo”, then click finish

selenium-webdriver-setup-11
 

5. Right click on the project select New -> Class

 selenium-webdriver-setup-12
 

Enter the Class Name. Our class name is "Demo".

Check the checkbox "public static void main (String args)"

Click on "Finish"

selenium-webdriver-setup-13
 

6. Write your program, we are adding a simple statement to write a message “Hello World” on console. After the changes, save the file (Press Ctrl+S)

public class Demo {

        public static void main(String[] args) {

                System.out.println("Hello World");

        }

}

selenium-webdriver-setup-14
 

7. To run program, Right Click on your java file (Demo.java in our case), select  -> "Run As" -> "Java Application"

   selenium-webdriver-setup-15
 

Check the output on console

 selenium-webdriver-setup-16
 

All Chapters
Author