
Setting up Eclipse IDE with Java project for Selenium WebDriver and TestNG
Here is a step by step explanation of setting up Eclipse IDE with Java project for the Selenium WebDriver and TestNG.
Downloading WebDriver JAR files
Download the Selenium WebDriver language bindings from http://docs.seleniumhq.org/download/. Unzip the downloaded Selenium WebDriver file; it will create a folder containing the Selenium WebDriver JAR files.
Downloading and installing Eclipse
Based on your system configuration type (32 bit or 64 bit), download the Eclipse IDE for the Java EE Developers Edition from http://www.eclipse.org/downloads/packages/release/Mars/M3. Save the file, as it is about to download somewhere on your disk drive. The exact form of this interaction will depend on which operating system you are using. Store this zip
file somewhere permanent on your disk drive so that you can unzip it (recreate Eclipse) later, if necessary.
Following are the steps that will install Eclipse on Windows:
- Unzip the file that you just downloaded. It creates a folder named
Eclipse
. You can leave this folder here or move it elsewhere on your disk drive. - Create a shortcut on your desktop to the
eclipse.exe
file. Now, you are ready to perform a one-time only setup of Eclipse. - Double-click on the shortcut to Eclipse that you just created. In the Workspace Launcher window, in the box following Workspace should appear something like
C:\Documents and Settings\username\workspace
(where username is your login name on the machine). If you want, you can type in (or browse) another location for the workspace file to be created, but I advise accepting the default. - In the Eclipse IDE, open the File menu, select New and Java Project to create a new project.
Configuring WebDriver with Eclipse
In the Package Explorer window, right-click on created project, select Build Path and Configure Build path…. The Java Build Path dialogue box appears. Click on the Add External Jars… button and choose the location where all your Selenium WebDriver JAR files are stored. Then click on OK on the Java Build Path dialogue box. Refer to the following screenshot in the Package Explorer window; you can see Referenced Libraries added to a project. This is how you need to configure the Selenium WebDriver to Eclipse:

TestNG plug-in installation for Eclipse
There is no need to download any JAR
or .exe
file for installation. We just need to utilize the Install New Software option available in Eclipse.
- Open Eclipse IDE, then click on Help on the menu bar and select Install New Software. The Install dialogue box appears.
- Type http://beust.com/eclipse in the Work with edit box. In the Name column, you can see TestNG. Click on the TestNG checkbox, and then click on the Next button:
- The Install dialogue box appears; select TestNG from the listed Name tab and click on the Next button. Click on the I accept the terms of the license agreement radio button and click on the Finish button.
This will install the TestNG plugin for Eclipse. After the installation, it will ask to restart Eclipse. Click on the Yes button. Once Eclipse is restarted, TestNG should be installed. To confirm whether it is installed successfully, first select the project, then click on Run from the Eclipse menu bar, and select the Run As option from the drop-down list. Here, you should be able to see TestNG Test. Refer to the following screenshot for the same:

We have successfully set up a project in the Selenium WebDriver. When we are working through the next chapters, we will know that they will have all the aspects that are needed.