Prerequisites required to setup Selenium Test Environment
Java Development Kit (JDK)
Eclipse IDE
Jar Files (Java Client Driver)
JDK
JDK (Java development Kit) is a Software development environment used for developing Java applications and applets, It includes JRE, Interpreter and a Compiler.
Steps to download JDK
Visit the Java downloads page on Oracle’s website to find the JDK environment Download
Go to the Oracle’s website URL Mentioned below http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Scroll down until you find Java SE Development Kit 7u79 tab appears as shown in below image.
Accept the Terms of Services as shown in below image
Choose the correct OS corresponding for the specific JDK (Windows, Mac, Linux, etc.)
On the “Computer” screen, click on the button that says “System Properties”, as seen below
To know your operating system On Windows 7 you can open the Start menu and choose “Computer” from the list as shown in below image
This will bring up a screen with information about your computer and version of Windows as shown in below Image
Steps to Install JDK
Once the download is complete, double click the file to begin the installation of JDK.
(Or)
After downloading JDK file you will find that file on same page in the browser or it will be in downloads Folder.
Right click on jdk-u79-windows-x...exe (downloaded file) and click "Show in folder" as shown in above Image.
It will navigate to downloads folder there Double click on jdk-u79-windows-x...exe
(Or)
Once the download is complete double click the file to begin the installation of JDK
You will be navigated to Pop-Up as shown in below Image
Click on Next button
Click on close button
After this step Java SE Development Kit is installed successfully.
Steps to set path in Environment variables
Go to start menu, right click on Computer, Select Properties
click on Advanced tab from the dialog box opened as shown in below image
click on Environment Variables
In system Variables tab, Click on Path variable and then click on Edit button as shown in below image
Pop-up will come as shown in below image , in that variable value give the path of bin folder of JDK (Go to c drive--programfiles, Java folder, then Jdk file, bin folder)
Go to JDK installed location, open bin folder available at the location. Now, copy the path.
Click on OK of Environment Variables window and System Properties window.
Verification of Path Setup
To verify whether Classpath or path of java is set up correctly or not.
Click on Start Menu in search program files textbox enter "cmd"
Open Command Prompt and enter "java -version". You'll find a statement like mentioned below:
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Steps to download Eclipse
Go to URL Mentioned below
You will find Eclipse IDE for Java EE Developers as shown below image
For Windows users, you will have to know what type of your OS you have. If your computer is a 64 bit windows, select Windows 64-bit and if you have a 32 bit windows, select Windows 32-bit
As our windows is 64-bit so we clicked on it
Click on Download button as shown in below image
After downloading you will get this message as shown below and you will find the downloaded file on the same page or it will be in downloads
Steps to configure Eclipse
Once you have downloaded the Eclipse archive you will need to decompress the zip file, which will create the unzipped Eclipse folder.
By extracting files as Right click on Zip file and click on Extract files….
You will find extracted folder as shown below
You may want to extract the archive to the root of D:\ drive, thus creating the folder “D:\eclipse”, or just moved the extracted eclipse folder to the root of D:\ drive if you extracted it already. Since Eclipse does not have any installer, there will be a file inside the Eclipse folder named eclipse.exe ( ). You can double click on the file to run Eclipse as shown in below image
It's better to create shortcut on Desktop
Double click on that Icon you will get a Pop-Up as shown below.
Click on 'Run' then you will get Workspace Launcher Pop-Up
In workspace we will specify the any folder path as every script we practice or project we do in eclipse will be store in that folder
If we click on the check box by default all the files will be stored in that folder and it will not ask you again when we open eclipse
After eclipse has been fully installed and extracted, create a workspace folder where you will contain all the program files you create.
Then click on OK button
Now that you have finished installing Eclipse, restart your computer. Restarting your computer refreshes system memory and allows registration or configuration changes made by installers and uninstallers to take effect.
Again double click on Eclipse button, above two steps will be repeated you will be navigated to Eclipse Home page as shown below
Steps for Creation of Java Project
Navigation for Creating Java Project
Click on File- New - Project as shown in below image
You will be navigated to Setup wizard Pop-Up as shown in below image
Select java Project---Click on Next button
You will be navigated to New Java Project Tab
In project name Textbox specify project name
Specify Project name in the Project name textbox and then click on Finish button
Steps for Creation of Package
Creation of Package
Right click on project select New and then click on package as shown in below image
Below Pop-up will appear then in the highlighted box specify package name
After specifying package name Finish button will be enabled then click on Finish button
Steps for creating class
Creation of Class
Right click on package, select New and then click on Class as shown in below image
Specify class name as shown in below and then click on Finish button
Example Program to show Output in Console
Steps to download Jar Files
Scroll down until you find Selenium client & WebDriver Language Bindings as shown in below image
As we are working with java platform so download java bindings
After downloading keep that file in specified folder and Extract that file
It will create folder as shown in below image
If you open that folder you will find libs folder and other two files as shown in below image
You will also find some files in libs folder as shown in below image
Steps to add Jar files to java Project
Now adding that jars to the project we created
Now right click on Project we created select Build Path and click on Configure Build Path…. As shown in below image
It will navigate us to next window as shown in below image
Now click on Libraries and then click on Add External JARs…
It will ask us to specify the folder where we saved the jar files
So go to the folder where we saved the files select the jars which are outside the libs folder then click on OK button as shown in below image
After the above step the added jars will be added to project as shown in below image
Also follow the same process to add jars which are inside the libs folder so after adding all jars it will be as shown in below image
Then click on OK button
After adding jars to the project it will be reflected in Package explorer as shown in below image
Steps for Installing TestNG
In Eclipse, from Help menu, click “Install New Software” as shown in below image
You will see a dialog window, click “Add” button as shown in below image
You will be navigated to Add Repository Pop-UP as shown in below image
Type name as “TestNG” and type “

You come back to the previous window but this time you must see TestNG option in the available in Software list. Just Click TestNG and press “Next” button as shown in below image
Follow the steps for Installing TestNG as shown in below images
Click “I accept the terms of the license agreement” then click Finish.
You may or may not encounter a Security warning, if in case you do just click OK
Click Next again on the succeeding dialog box until it prompts you to Restart the Eclipse.
You are all done now, just click Yes.
Proceed with your workplace.
After restart, verify if TestNG was indeed successfully installed. Right click on you project and see if TestNG is displayed in the opened menu as shown in below image
Steps to Create TestNG class
TestNG class don't have any main method, Here @Test annotation is default for all TestNG classes and remaining annotations are optional
Give a name to the testng class(Ex: Sample), and specify a name to the testng.xml file(Ex: TestNG.xml), finally click on Finish
Then you can find some thing like this in your package Explorer.
If you open them(Sample.java & TestNG.xml..), they will look like in the below image
You can run Sample.java file as
TestNG class or you can run a batch of TestNG classes
using
TestNG.xml
test-output:
Just right click on the project and refresh it, a new folder with all the reports will generate, if you open it you can find all the reports related to your tests.
The above info is all about creation of Testing environment for Selenium in eclipse using
TestNG framework
Thank you............................Prasad
No comments:
Post a Comment