Selenium WebDriver- Installation
Selenium WebDriver installation process is completed in four basic steps:
- Download and Install Java 8 or higher version.
- Download and configure Eclipse or any Java IDE of your choice.
- Download Selenium WebDriver Java Client
- Configure Selenium WebDriver
1. Download and Install Java
We assume that you have already installed Java 8 or above on your machine and successfully configured the environment variables required to run and compile java programs.
Note: you'll need to have Java 8 installed to use Selenium 3.
However, you can download the latest version of Java Development Kit (JDK) from the link given below.
Once you have downloaded and installed the latest version of Java, you need to set path or configure the environment variables in your system. Refer the link given below to understand how we can set path and configure environment variables in Java.
2. Download and Configure Eclipse IDE
- Open URL: https://www.eclipse.org/downloads/ .
- Click on the "Download Packages" link (you can also download the IDE directly from the "downloads page" of Eclipse official website, but we will recommend you to navigate through the download packages section and get "Eclipse IDE for Java Developers").
- It will redirect you to the "Download Packages" section. Scroll down through the webpage and click on "Eclipse IDE for Java Developers".
- Go to the Download Links section and click on "Windows 64-bit". You can also select other options to download based on the operating system you are currently working on.
- The downloaded file would be in zipped format. Unpack the contents in a convenient directory.
- Double click on "eclipse" (.exe file).
- To configure the workspace, select a convenient directory where you want to keep all of your Selenium trails and click on Launch button.
- It will launch the default interface of Eclipse IDE.
3. Download Selenium WebDriver Java Client
- Open URL: https://docs.seleniumhq.org/download/
It will redirect you to the "downloads page" of Selenium official website.
- Scroll down through the web page and locate Selenium Client & WebDriver Language Bindings.
- Click on the "Download" link of Java Client Driver as shown in the image given below.
- The downloaded file would be in zipped format. Unpack the contents in a convenient directory. It contains the essential jar files required to configure Selenium WebDriver in Eclipse IDE.
4. Configure Selenium WebDriver
Now we will configure our Eclipse IDE with Selenium WebDriver. In simple terms, we will create a new Java Project in Eclipse and load all the essential jar files in order to create Selenium Test Scripts.
- Launch Eclipse IDE
- Create a new Java Project from File > New > Java Project.
- Give your Project name as "Demo_Test", leave the other fields unaltered and click on "Finish" button.
- It will create a new Java project with the following directories.
Note: Selenium Test Scripts are always written in ".class" file in Java. Here the project "Demo_Test" act as a Test Suite that may contain one or more Selenium test cases/test scripts.
- Right click on the "src" folder and create a new Class File from New > Class.
- Give your Class name as "First" and click on "Finish" button.
Now, we will add the Selenium jar files in our Test Suite (Demo_Test).
- Right click on "Demo_Test" folder and select Properties.
- It will launch the Properties window for our "Demo_Test" Test Suite.
- Click on "Java Build Path" option from the left hand side panel.
- Switch to Libraries tab and click on "Add External JARs" button.
- Locate the directory where you have downloaded the Selenium jar files, select the respective jars and click on "Open" button.
- Repeat the same steps for the jars which are present under the "libs" folder.
- Open "libs" folder, select all of the respective jar files and click on "Open" button.
- Once you get all the Selenium jar files in your Libraries tab, click on Apply and Close button.
- The following image shows the directory structure of our "Demo_Test" test suite after adding Selenium jars.
Hence, we have successfully configured Selenium WebDriver with Eclipse IDE. Now, we are ready to write our test scripts in Eclipse and run it in WebDriver.