In this tutorial we will install Webdriver (Java only) and Configure Eclipse
Step 1 - Install Java on your computer
Download and install the Java Software Development Kit (JDK) here.
This JDK version comes bundled with Java Runtime Environment (JRE) so you do not need to download and install the JRE separately.
Step 2 - Install Eclipse IDE
Download "Eclipse IDE for Java Developers" here. Be sure to choose correctly between Windows 32 Bit and 64 Bit versions.
You should be able to download a ZIP file named "eclipse-java-juno-SR1-win32-x86_64.zip" (the version number "SR1" may change over time).
Inside that ZIP file, there is an "eclipse" folder which contains all the application files. You can extract the "eclipse" folder anywhere you want in your PC; but for this tutorial, extract it to your C drive.
Unlike other popular software , no installation is required to use eclipse.
Step 3 - Download the Selenium Java Client Driver
You can download the Selenium Java Client Driver here. You will find client drivers for other languages there, but only choose the one for Java.
This download comes as a ZIP file named "selenium-2.25.0.zip". For simplicity, extract the contents of this ZIP file on your C drive so that you would have the directory "C:\selenium-2.25.0\". This directory contains all the JAR files that we would later import on Eclipse.
Step 4 - Configure Eclipse IDE with WebDriver
- Launch the "eclipse.exe" file inside the "eclipse" folder that we extracted in step 2. If you followed step 2 correctly, the executable should be located on C:\eclipse\eclipse.exe.
- When asked to select for a workspace, just accept the default location.
- Create a new project through File > New > Java Project. Name the project as "myproject".
- Right-click on the newly created project and select New > Package, and name that package as "mypackage".
- Create a new Java class under mypackage by right-clicking on it and then selecting New > Class, and then name it as "myclass". Your Eclipse IDE should look like the image below.
- Right-click on myproject and select Properties.
- On the Properties dialog, click on "Java Build Path".
- Click on the Libraries tab, and then click "Add External JARs.."
- Navigate to C:\selenium-2.25.0\ (or any other location where you saved the extracted contents of "selenium-2.25.0.zip" in step 3).
- Add all the JAR files inside and outside the "libs" folder. Your Properties dialog should now look similar to the image below.
- Finally, click OK and we are done importing Selenium libraries into our project.
HTMLUnit and Firefox are two browsers that WebDriver can directly automate - meaning that no other separate component is needed to install or run while the test is being executed. For other browsers, a separate program is needed. That program is called as the Driver Server.
A driver server is different for each browser. For example, Internet Explorer has its own driver server which you cannot use on other browsers. Below is the list of driver servers and the corresponding browsers that use them.
Name of Driver Server
WebDriver can drive HTMLUnit without the need of a driver server
WebDriver can drive Firefox without the need of a driver server
Internet Explorer Driver Server
Available in 32 and 64-bit versions. Use the version that corresponds to the architecture of your IE
Though its name is just "ChromeDriver", it is in fact a Driver Server, not just a driver. The current version can support versions higher than Chrome v.21
Though its name is just "OperaDriver", it is in fact a Driver Server, not just a driver.
PhantomJS is another headless browser just like HTMLUnit.
Though its name is just "SafariDriver", it is in fact a Driver Server, not just a driver.
You can download these driver servers here
- Aside from a browser, you will need the following to start using WebDriver
- Java Development Kit (JDK). http://www.oracle.com/technetwork/java/javase/downloads/index.html
- Eclipse IDE - http://www.eclipse.org/downloads/
- Java Client Driver - http://seleniumhq.org/download/
- When starting a WebDriver project in Eclipse, do not forget to import the Java Client Driver files onto your project. These files will constitute your Selenium Library.
- HTMLUnit and Firefox are the only browsers that you can automate without the use of a Driver Server.
- Each other browser has its own driver server.