Netsparker Web Application Security Scanner

Getting Started With Installation Of Selenium WebDriver - Learn Selenium

In this chapter, we are going to install Selenium WebDriver using JAVA language and configure it with Eclipse MARS.1 version.Below are the steps.

Step 1: Install Java on your computer:

Check if your system already has Java runtime environment (JRE) or (Java Development Kit) JDK installed on your machine. If not, then it could be downloaded and installed from below link.

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

 

Selenium Install 1.1

 

It is recommended to install JavaSE-1.8 and higher version to work with Eclipse IDE and Selenium Java Client Driver

Difference between JRE and JDK

JDK (Java SE Development Kit) includes complete JRE libraries as well as tools for developing, debugging, and monitoring Java applications. Therefore JDK is the superset of JRE.

 

Step 2: Install Eclipse IDE:

  • Enter the URL (http://www.eclipse.org/downloads/packages/release/Mars/2) in the web browser and click on the download link to download eclipse IDE. We are using Eclipse MARS version here.
  • Unzip the eclipse package and provide the system with installed JRE 8/JavaSE-1.8 (Java Runtime Path) for javaw.exe file for eclipse to work. The file eclipse.ini present in eclipse directory has the javaw.exe path which helps in starting the eclipse IDE.
  • When eclipse MARS.1 starts, it will ask you to choose a workspace. Select an appropriate location such as “C:\Selenium_Workpace” and click OK to complete this step as shown below.

 

Selenium workspace

 

  • At this point Eclipse IDE is ready to use.

 

Step 3 – Download the Selenium Java Client Driver

Selenium Java Client Driver are the number of JARS file which could be downloaded from the below link.

http://docs.seleniumhq.org/download/ .

Click on the ‘Download’ link present against Java language for the latest version available as 2.53.0 as shown below. Keep all the downloaded jar files at one place which will be referred by the Selenium tests during runtime.

 

Selenium Install 0

 

Step 4: Configure Eclipse IDE with WebDriver

At this point, we have downloaded and installed JRE, Eclipse MARS.1 and Selenium WebDriver client jars. Now, we need to configure eclipse IDE with downloaded WebDriver. Following are the steps to do so.

  • Click on the ‘File’ link present at the top menu and navigate through links as New ->Others… as shown below.

 

Selenium Install 2

 

  • On completion of the above step, a dialogue box will be opened as shown below. Type Java to filter the available options present in the wizard and select ‘Java Project’ and then click on the Next button.

 

Selenium Install 1

 

  • On completion of the above step, the system will display another dialogue box asking you to provide the project name. Here, we are giving project name as ‘selenium-webdriver-config’ as shown below. Choose the default workspace location and installed JRE/JavaSE-1.8 as the Java runtime environment and then click on the ‘Next’ button.

 

Selenium Install 3

 

  • On the completion of the above step, the system will open up Java Settings dialogue box as shown below. Keep the default settings and click on the Finish button.

 

Selenium Install 4

 

  • The series of above steps will create a Java project with the given name and the Java JRE/JavaSE-1.8 as the runtime environment. Next we need to create a Java class in the Java project which will refer ‘Selenium webdriver’ for the actual test.
  • Right click on the Java project name that was created before and navigate through links as New >> Class as shown below.

 

Selenium Install 5

 

  • On the completion of the above step, it will open up ‘New Java Class’ dialogue box. Enter the Java package and class name. Here, we have entered package name as ‘seleniumpackage’ and Java class name as ‘SeleniumTestClass’.Rest keep the default settings and click on the ‘Finish’ button to commit the current developments.

 

Selenium new class

 

  • Next we need to configure the build path by adding the WebDriver client jars at the java classpath. To do so, right click on the Java project and navigate through links Build Path à Configure Build Path… as shown below.

 

Selenium Install 6

 

  • On the completion of the above step, the system will open up a ‘Java Build Path’ dialogue box as shown below. Click on the ‘Add External JARs…’ button to add WebDriver client JARs.

 

Selenium Install 7

 

  • On clicking that button, the system will ask for JAR Selection. Navigate into your machine to the directory where Selenium WebDriver JARs were downloaded before, select all of those JARs and click on the Open button as shown below.

 

Selenium Install 8

 

  • At this point the Build Path is set as it has all the required Selenium WebDriver JARs. When you expand the Referenced Libraries icon present in the Package Explorer, you can see all the Selenium WebDriver client JARs present at the classpath as shown below.

 

Selenium Install 9

 

At this point, your system is ready to work with Selenium Webdriver which is configured with eclipse IDE running with JavaSE-1.8.

 

Different Commonly Used WebDrivers:

Using Selenium WebDriver, we can directly automate tests using web browsers such as HTMLUnit and Firefox as these browsers do not require any other separate component to be installed while executing tests. However, in order to execute tests using other web browsers we need to install additional components for WebDriver to work smoothly. Such component is known as Driver Server.Each browser other than HTMLUnit and Firefox has a different driver server. Following is the list of driver servers.

BrowserDriver ServerDescription
HTMLUnitNot ApplicableWebDriver can drive tests without any additional component with HTMLUnit browser.
FirefoxNot ApplicableWebDriver can drive tests without any additional component with Firefox browser.
MS Internet Explorer (IE)Internet Explorer Driver ServerIE driver server is available in 32 and 64-bit versions. This is to be noted that use the driver server version that corresponds to your IE architecture.
Google ChromeChromeDriverChromeDriver is a Driver Server that can support versions higher than Chrome v.21.
OperaOperaDriverOperaDriver is a Driver Server, not just a driver.
PhantomJSGhostDriverThis browser is just like HTMLUnit, though it requires GhostDriver as the Driver Server.
Apple SafariSafariDriverSafariDriver is a Driver Server, not just a driver.

 

All of the above Driver servers mentioned above can be downloaded from the below link.

http://docs.seleniumhq.org/download/

 

Conclusion:

We need JavaSE-1.8 or Java Runtime Environment, Eclipse MARS.1 IDE and Selenium Webdriver that works default with HTMLUnit and Firefox web browsers. If we want to test web application on different web browsers other than these then we need to download and install additional component known as Driver server as explained above. With all these software are component, our Selenium WebDriver test environment is ready to use.

If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:

Enter your email address:

Check email in your inbox for confirmation to get latest updates Software Testing for free.

Happy Testing!!!

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>