Selenium Web Driver Environment Setup With J UNIT 4 and eclipse IDE


This Document Provides Instruction about setting a testing Environment for Selenium Web driver and J-Unit 4.


Contents


Setting up IDE:

Installing Fire Fox Add-ons:
  1. First download Mozilla Firefox browser.
  2. Click on the Firefox tab present at the top the browser window.
http://pad2.whstatic.com/images/thumb/8/8a/Download-Selenium-IDE-Addon-Step-3-Version-2.jpg/670px-Download-Selenium-IDE-Addon-Step-3-Version-2.jpg
  1. In drop down menu click on Add-on.
          http://pad3.whstatic.com/images/thumb/e/e4/Download-Selenium-IDE-Addon-Step-4-Version-2.jpg/670px-Download-Selenium-IDE-Addon-Step-4-Version-2.jpg

  1. Go to add on page of Mozilla Firefox browser. In the search box of Add on page search the term “Selenium IDE” and press enter


 http://pad1.whstatic.com/images/thumb/e/e1/Download-Selenium-IDE-Addon-Step-5-Version-2.jpg/670px-Download-Selenium-IDE-Addon-Step-5-Version-2.jpg


  1. A page will open which displays Selenium IDE add-on.
http://pad3.whstatic.com/images/thumb/8/81/Download-Selenium-IDE-Addon-Step-5Bullet1.jpg/670px-Download-Selenium-IDE-Addon-Step-5Bullet1.jpg
  1. Click on install next to the Selenium IDE add-on
http://pad2.whstatic.com/images/thumb/3/32/Download-Selenium-IDE-Addon-Step-6-Version-2.jpg/670px-Download-Selenium-IDE-Addon-Step-6-Version-2.jpg
  1. Once installation is done the Mozilla Firefox browser will ask you to restart the browser.
http://pad1.whstatic.com/images/thumb/6/60/Download-Selenium-IDE-Addon-Step-7-Version-2.jpg/670px-Download-Selenium-IDE-Addon-Step-7-Version-2.jpg


Validating Installation:
  1. Open Tools Menu in Fire Fox Web Browser.
  1. Verify Presence of “Selenium IDE”.

Setting up Java Environment:

Downloading and Installing JDK and JRE:
  1. Download the latest version of the Java JDK from Sun Microsystems.
http://pad1.whstatic.com/images/thumb/8/83/Install-the-Java-Software-Development-Kit-Step-1.jpg/670px-Install-the-Java-Software-Development-Kit-Step-1.jpg
  1. Double-click on the install file and it should open an installer.
http://pad2.whstatic.com/images/thumb/1/18/Install-the-Java-Software-Development-Kit-Step-2.jpg/670px-Install-the-Java-Software-Development-Kit-Step-2.jpg
  1. Wait Until Installation Completes.
Setting Environment Variables for JVM:
  1. Open the properties of “My Computer” by either right-clicking the icon on the desktop or right-clicking Start > My Computer. When the pop up menu opens, scroll to the bottom and select “Properties”.
http://pad3.whstatic.com/images/thumb/8/8b/Install-the-Java-Software-Development-Kit-Step-10.jpg/670px-Install-the-Java-Software-Development-Kit-Step-10.jpg
  1. This should open a window named “System Properties”. Click on the “Advanced” tab and then click “Environment Variables”
http://pad3.whstatic.com/images/thumb/a/a2/Install-the-Java-Software-Development-Kit-Step-11.jpg/670px-Install-the-Java-Software-Development-Kit-Step-11.jpg


  1. Next, another window opens with a lot of confusing sentences and letters. Double-click on the “Path” variable on either of the option boxes. It is recommended to edit the variable in the box “User variables for (your username)
  2. Once the variable is opened, a text box in yet another window appears. Careful not to delete anything in this box. At the end of the text box, add a semi-colon if there is not one already, and add “C:\Program Files\Java\jdk1.6.0\bin” to the text box. This is assuming you did not change the file path of the installation.
  3. Click “Apply” and “OK” to all the windows you have just opened. Open the command prompt again, “java” command works then Environment Variable are correctly Set.
Downloading and Installing Eclipse:
  1. Go to the Eclipse Downloads website , and the following webpage will open up.
  2. Choose the appropriate version of Eclipse IDE for your operating system and Java installation.
  • Look for “Eclipse IDE for Java Developers” and on its right hand side, there are two versions of Eclipse available (32 bit and 64 bit).
  • If you have 32 bit version of Java, choose 32 bit version of Eclipse and if your using 64-bit Java, choose 64 bit version of Eclipse IDE
  • If not sure about the configuration of your operating system, choose the 32 bit version of Eclipse IDE as it works on both 32 bit operating system and 64 bit operating system
  • Note: – It is important to choose the same version of Eclipse and Java because if you mix 32/64 bit Java/Eclipse then Eclipse might not work.
  1. Once the right version selected, you will be directed to the mirror selection page:
  • Proceed with the download by clicking on the Green arrow pointing downward.
  • The download of eclipse-java-indigo-SR1-win32.zip will begin.
  • Note: – Save the file to a convenient location like C:/ drive or Desktop.
  • When the download finishes, proceed to the step 4.
  1. Unzip the file: – The downloaded file will be a zipped folder, so in order to access its contents we need to unzip the file as follows:-
  • Find the eclipse-java-indigo-SR1-win32.zip from where you saved it.
  • Double click on it.
  • The file will open with the default extraction wizard(i.e WinZip or WinRAR)
  • Once the extraction/Unzipping is complete, you will be able to see a folder named “eclipse”.
  1. Eclipse does not have any installer, that’s why we need to Run “eclipse”, an application within the eclipse folder as follows:-
  • Double Click on the eclipse folder.
  • In the eclipse folder, look for an application named “eclipse”; it has a round purple icon with white horizontal lines.
  • Double click on it to run eclipse.


Selenium Web Driver Bindings:

Downloading Selenium Web Driver J-Unit Bindings:
  1. Download Selenium Client & Web Driver Language Bindings from Selenium website.
  2. Extract downloaded ZIP file to intended location (keep some permanent one, as you will need them for a long time)
Using Web driver Bindings in J-Unit Project:
  1. Create new Java project in Eclipse
  2. Add all extracted JARs (also these in lib folder) to Java Build Path in project Properties

First Test Project:

Recording Test Script in IDE:
  1. Open new tab in Mozilla Firefox browser.
  2. Open selenium IDE.
  3. Click on “Record” button. (Please note here. It will start recording all navigation and action once you click on “Record” button.
  4. Now enter URL “https://www.google.co.in/” in your browser. (Selenium IDE will record that action. Make sure your recording is working fine.)
  5. Click on “Images” link displayed in main menu.
  6. Click on “Maps” link displayed in main menu.
  7. Click on “Play” link displayed in main menu.
  8. Stop Selenium IDE recording by clicking on “Stop Record” button. Your recording is completed now.
  9. My script will looks like bellow in selenium IDE.
New Test
Command
Target
Value
open
clickAndWait
css=#gb_2 > span.gbts
assertTitle
Google Images
clickAndWait
css=#gb_8 > span.gbts
assertTitle
Google Maps
clickAndWait
css=#gb_78 > span.gbts
assertTitle
Google Play

Exporting IDE Test Script in Web Driver J-Unit:
  1. After Recording Test case successfully. Open File From Menu.
  2. And Export Test Case AS “Java/J Unit/ Web driver” file.

Creating Test Project in Eclipse:
  1. Create new Java project in Eclipse
  2. Add all extracted JARs (also these in lib folder) to Java Build Path in project Properties.
  3. Add the Exported Code from Selenium IDE in Eclipse Project.
  4. Click Run Button in mwnue.

Good to Read Links:

Selenium Web Driver Command Set:
Helpful Tutorials:

Refrence
WikiHow.com 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s