Back

Installation and Configuration of Selenium Webdriver

Posted 8/21/14
18 Comments

We previously looked at Selenium Webdriver's features and advantages, and how to integrate it with Jmeter.  In this post we'll explore installation and configuation.  Selenium Webdriver Scripts can be generated in various programming languages depending upon the Requirements and skills. Here, Java is used to generate the Webdriver scripts in Eclipse.

Steps to configure java with eclipse

 

Step 2 - Download and install Eclipse

 

Step 3 - Download Selenium Java Client Driver

Select only Java Client driver and download. After downloading, unzip it and a folder contains 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.

 

Step 4 - Download selenium-server-standalone-2.42.2 jar file.

Save this Selenium server file in the same folder as above that is, Selenium-2.42.2 folder.

Step 5 - Create a new Project in Eclipse.

-Open Eclipse executable file and create a new workspace.

-Now in Eclipse, create a new project by clicking on File menu –> New –> Java Project ->

-Name the project as 'TestProject'  and click finish.

- Create a new Java class by clicking on File menu –> New -> Class then name it as 'TestClass' and select the checkbox for 'public static void main (String[] args) and click finish.

- Now Right-click on testproject and select Build Path -> Configure Build Path and click Add External Jars button for sidebar .
- Navigate to the location where Selenium 2.42.2 folder is saved and add Selenium-java-2.42.2, selenium-java-2.42.2-srcs, selenium-server-standalone-2.42.2 jar files and all the jar files in the libs folder and click ok button.
-Your Properties window after adding all the jar file should now look similar to the image below.

Step 5 - Run the Sample Program.

Lets run the sample program in Firefox driver. Firefox driver is included in the selenium-server-standalone jar  file. The driver comes in the form of an xpi (firefox extension) which is added to the firefox profile when you start a new instance of FirefoxDriver.

Usage :

WebDriver driver = new FirefoxDriver();

Sample code

package org.openqa.selenium.example;i

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.firefox.FirefoxDriver;

public class Example  {

    public static void main(String[] args) {         

                WebDriver driver = new FirefoxDriver();

                System.out.println("Firefox is opened");

                driver.get("http://www.google.com");

                Sytem.out.println("Google is selected");

// Find the text input element by its name

               WebElement element = driver.findElement(By.name("q"));

// Enter something to search

               element.sendKeys("Cheese!");            

//Now submit the form to get the result from the element
               element.submit();

 // Check the title of the page

               System.out.println("Page title is: " + driver.getTitle());

               }

}

The above code should open Firefox browser and search for Cheese! keyword and display the results. And in Eclipse console window, the result should be displayed as below.

This successfully installs and run all the above things. Since Firefox is included in selenium server jar file itself, there wasn't any need to install Firefox driver but if there is a need to run the code in other browsers like  Chrome, IE (IE 6 and above) and Safari, then the respective browser drivers need to be downloaded.

Internet Explorer Driver

The InternetExplorerDriver is a standalone server which implements WebDriver wire protocol. This driver has been tested with IE 6, 7, 8 and 9 on appropriate combinations of XP, Vista and Windows 7.

The driver supports running 32-bit and 64-bit versions of the browser. The choice of how to determine which "bit-ness" to use in launching the browser depends on which version of the IEDriverServer.exe is launched.

Download the 32-bit and 64-bit versions jar files and save it in the C drive.

Usage :

            WebDriver driver = new InternetExplorerDriver();

Required Configuration

  • The IEDriverServer executable must be placed in your PATH.

               Example: Path= C:\Program Files\ IEDriverServer_x64_2.42.0\IEDriverServer

  • On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".
  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.

Sample code

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.ie.InternetExplorerDriver;

public class Example  {

    public static void main(String[] args) {

           //System.setProperty("webdriver.ie.driver", "Path where it is saved");

      System.setProperty("webdriver.ie.driver","C:\\Program  Files\\Java\\IEDriverServer.exe");

           System.out.println(System.getProperty("webdriver.ie.driver"));

           WebDriver driver = new InternetExplorerDriver();

           System.out.println("IE is selected");

           driver.get("http://www.google.com");

           System.out.println("Google is selected");

           // Find the text input element by its name

           WebElement element = driver.findElement(By.name("q"));

           // Enter something to search

           element.sendKeys("Cheese!");

           // Now submit the form to get the result

           element.submit();

           // Check the title of the page

           System.out.println("Page title is: " + driver.getTitle());

           }

 }

The above code should open IE browser and search for Cheese! keyword and display the results. IE is slow compared to other browsers, so have to wait patiently till it loads. And in Eclipse console window, the result should be displayed as below.

Chrome Driver

The ChromeDriver Developed in collaboration with the Chromium team, the ChromeDriver is a standalone server which implements WebDriver wire protocol.

The ChromeDriver consists of three separate pieces. There is the browser itself ("chrome"), the language bindings provided by the Selenium project ("the driver") and an executable downloaded from the Chromium project which acts as a bridge between "chrome" and the "driver". This executable is called "ChromeDriver".

Required Configuration

  • To get set up, first download the appropriate server. Make sure the server can be located on your PATH 

            Example: Path= C:\Program Files\chromedriver_win_23.0.1240.0\chromedriver.exe

Usage :

WebDriver driver = new ChromeDriver();

Sample code:

package org.openqa.selenium.example;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

public class Example  {

    public static void main(String[] args) {

         //chrome

System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Java\\chromedriver.exe");

            System.out.println(System.getProperty("webdriver.chrome.driver"));

            WebDriver driver = new ChromeDriver();

            System.out.println("Chrome is selected");                              

            driver.get("http://www.google.com");

            System.out.println("Google is selected");                              

            // Find the text input element by its name

            WebElement element = driver.findElement(By.name("q"));

            // Enter any key to search

            element.sendKeys("Cheese!");

            // Submit the form to get the result

            element.submit();

          // Check the title of the page

            System.out.println("Page title is: " + driver.getTitle());

            }

}

The above code should open Chrome browser and search for Cheese! keyword and display the results. And in Eclipse console window, the result should be displayed as below.

Apart from these browsers, Web Applications can also be automated in other browsers, and their drivers can be downloaded from http://docs.seleniumhq.org/download/ under Third Party Browser Drivers section.

Comments
Add Comment
Sherlin Jones
Hey Salma,

Thanks for sharing a great article on Selenium Installation steps.

I think there are lots of people who struggle while configuring Selenium.

I have also tried my best to write on Selenium installation which will be helpful to people who are stepping into Selenium Automation.

I request you to please provide your feedback for the same, it would be a great help!!
http://seleniumtutorialandtraining.blogspot.in/2017/03/installation-of-selenium-ide-step-by.html

Thanks a lot!!
Posted on 3/26/17 5:48 AM.
Savithaa Nirmal
Very good article about consent workshop. <a href="http://www.credosystemz.com/training-in-chennai/best-selenium-training-in-chennai/">Selenium Training in Velachery </a> gives 2 days entire thing about Automation Testing and the different tools used in the industry.
Posted on 4/23/17 7:58 AM.
Nassim Hamadouche
Hey ,
Thanks for sharing this article.
can you share explanation about how to run java test in command line ?
Posted on 6/21/18 8:22 AM.
logistic solutions
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
<a href="http://squares.co.in/">sap supplier diversity management services</a>
<a href="http://squares.co.in/">sap supplier diversity management solutions</a>
Posted on 7/6/18 6:41 AM.
bala D
hi,
thanks for your article. It is clearly to explain the installation and configuration of selenium.<a href="https://www.besanttechnologies.com/training-courses/software-testing-training/selenium-training-institute-in-chennai">Selenium Training in Chennai</a>
Posted on 7/20/18 1:51 AM.
kavi G
Good job.A lot of doubts about configuration webdriver is clears in this article.Thanks for sharing.check this also<a href="http://www.bestseleniumtraininginchennai.in/"> selenium training in chennai </a>
<a href="http://www.bestseleniumtraininginchennai.in/">selenium training in velachery </a>
Posted on 10/3/18 2:26 AM.
kavi G
Nice blog.Thank you.Check this likehttp://www.bestseleniumtraininginchennai.in/
Posted on 10/3/18 2:28 AM.
kavi G
http://www.bestseleniumtraininginchennai.in/
Posted on 10/3/18 2:30 AM.
jaya priya
This pretty much applies to every job profile. Dissatisfaction , politics and people expecting you to know and do everything . I believe job positions that are extremely close to business side of things will be more rewarding .
Decisions you take and mistakes you make must have the shortest path to revenue impacts , That is a place where you will be respected.
<a href="https://www.besanttechnologies.com/training-courses/software-testing-training/selenium-training-institute-in-chennai">Selenium training in Chennai</a>
Posted on 12/24/18 2:02 AM.
sasi viamla
After reading this web site I am very satisfied simply because this site is providing comprehensive knowledge for you to audience.
Thank you to the perform as well as discuss anything incredibly important in my opinion. We loose time waiting for your next article writing in addition to I beg one to get back to pay a visit to our website in


<a href="http://www.trainingbangalore.in/selenium-training-in-bangalore.html">Selenium training in bangalore </a>
Posted on 2/8/19 5:58 AM.
VRIT PROFESSIONALS
Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
Thanks & Regards,
VRIT Professionals,
Web Designing Training Institute in Chennai,
http://www.vritp.com
Posted on 2/10/19 10:18 AM.
Zuan Education
The article on Installation and Configuration of Selenium Webdriver seems to be more informative. This is more helpful for our <a href="https://www.zuaneducation.com/selenium-training-chennai"> Selenium training</a> in Chennai. Thanks for sharing
Posted on 5/4/19 4:57 AM.
Kiruthika Venkatesh
Thanks for Sharing this article..
It seems to be more informative...
<a href="https://www.besanttechnologies.com/training-courses/software-testing-training/selenium-training-institute-in-chennai?utm_source=backlinks&utm_medium=cmt&utm_campaign=coursepage&utm_term=selenium&utm_content=kiruthika"> Selenium Training in Chennai </a>
Posted on 5/13/19 1:56 AM.
Zuan Education
The above article "Installation and Configuration of Selenium Webdriver" seems to be more informative. This is more helpful for our <a href="https://www.zuaneducation.com/selenium-training-chennai">selenium classes</a> in Chennai. Thanks for sharing
Posted on 5/13/19 3:48 AM.
dhekitha kutty
Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
https://www.gangboard.com/microsoft/windows-azure-training?utm_source=backlinks&utm_medium=cmt&utm_campaign=coursepage&utm_term=microsoftazure&utm_content=jp
Posted on 5/20/19 12:36 AM.
Zuan Education
The article seems to be more informative. This is more helpful for our <a href="https://www.zuaneducation.com/selenium-training-chennai">selenium training in chennai</a> Thanks for sharing
Posted on 5/20/19 1:25 AM.
venkat cheyat
"http://cheyat.com/qa/uft-online-training-and-tutorials.html"> Oracle Plql Online Training </a>
Posted on 6/3/19 2:11 AM.
preji p
Great article. Thank you for the details about selenium
Do check http://www.besanttechnologies.in/selenium-training-in-chennai.html
Posted on 7/10/19 1:51 AM.

Contact Us

character(s) remaining