Tuesday 4 March 2014

How to set up selenium IDE , RC and TestNG Environment.



Installation steps for Selenium IDE
The pre-requisite for installing Selenium IDE is to have a Mozilla FireFox installed in the machine with a 3X or later version as Selenium IDE is an add-on to FireFox.
22)   Click on Download version 1.6.0 (at the time of writing this) under Selenium IDE
33) Click on Allow button on the pop-up blocker
44) Click on Install Now button on the opened pop-up
55)After the Installation click on Restart FireFox for complete setup.

Installation steps for Selenium RC
The pre-requisites to install RC are to have Java 1.5 or above version and Eclipse IDE installed in your machine.
11) You can download and install Java from the following URL http://www.oracle.com/technetwork/java/javase/downloads/index.html
22)You can download and install Eclipse from the following URL
Extract the Zip Folder and run the eclipse.exe File. There is no separate installation required rather than running the .Exe file.
33)   Now go to http://seleniumhq.org/download/ and click on Download version 2.19.0(at the time of writing) under Selenium Server section
44)   Now click on download link under selenium Client drivers for your desired language.
For E.g. To download Selenium Java client drivers, click on Download link for Java
55)  Extract the Client drivers into to your Local disk.
66)   Now open Eclipse IDE.
77)     Create a New Project (Right Click on Project Explore  à Newàselect Java Project  à Give the name and click on Finish.
88)   Right click on the Projectà Build Pathà Configure Build PathàLibraries tabàAdd External Jars.
99)     Add the following list of jars to the libraries
1. Selenium-server-standalone-2.14.0
2. selenium-java-2.14.0
3. selenium-java-2.14.0-srcs
110). Click on Ok to complete the setup.

Configuring TestNG Framework to Selenium RC
11)    Go to http://testng.org/doc/download.html and download the latest version of TestNG.
22)     Extract the  zip file to your local disk
33)    Go to Eclipse and add the testng-6.3.1.jar file to the external jar files as above.
44)     Now go to Help Menu and click on Install New Software
55)     Click on Add button
66)     Give the Name as TestNG (you can give any name, but we prefer TestNG)
77)    In the location provide the following URL and click on OK
 http://beust.com/eclipse (For Eclipse 3.4 and above)
 http://beust.com/eclipse1 (For Eclipse 3.3 and below)
88)     Now Check the checkbox TestNG and click on Next to install the TestNG

Steps to Run Selenium Server
Before starting the execution of your scripts on selenium RC we have to start the selenium server. Following are the steps to start your server.
11)     Open command prompt
22)    Type cmd
33)     Go to the location where your selenium-standalone-server2.14.0.jar resided
44)     Now type the following command at command prompt to start the server.
java –jar selenium-standalone-server-2.14.0.jar

Creating a Batch File for Selenium server:
1.     Open Notepad and type the following text

D:
cd Selenium\
java -jar selenium-server-standalone-2.14.0.jar
              (Here I assumed that your server is at D: drive)
2.     Now save the File as server.bat on your desktop.
3.     Now whenever you want to start the server you just run this batch file. When the server starts running you can see the following screenshot on your desktop.




Setting up iPhone User Agent in Mozilla Firefox:
Manual Testing with iPhone User Agent:
          For testing the application manually, we need to add iPhone User Agent as an Add-On in Mozilla Firefox. The steps to do that are as below:
·       Open Firefox.
·       Click on “Add to Firefox” button. It’ll install the User Agent Switcher as an Add-On.
·       Restart Firefox and then go to Tools -> Default User Agent -> Select iPhone3.0
·       Don’t close the browser. Rather, open a new tab and then type any URL (For e.g. www.yahoomail.com) in the address bar. You would be able to see the website as per the selected iPhone user agent.
·       After that you can carry on with the testing of website as viewed in iPhone mobile browser.
Note: If you close the browser after selecting the iPhone 3.0 user agent and on opening a fresh new browser, you will see the Default User Agent as selected and you need to re-select the iPhone 3.0 user agent again.

Automation Testing (Selenium) with iPhone User Agent:
          For testing the application with Selenium scripts and iPhone User Agent, you need to do the following steps:
·       Create a Firefox Profile. Steps for creating Firefox profile are as below:
1.     Make sure all your Firefox instances are closed.
2.     Click Start -> Run
3.     Type “firefox.exe -ProfileManager -no-remote”.
4.     Select “Create Profile” (i.e. selenium).
5.     Click “Next”.
6.     Enter new profile name, e.g., iPhone.
7.     Select a directory folder to store your new profile. You can do that by clicking on Choose Folder button.
8.     Click “Finish”
9.     Select “Don’t ask at startup”.
10. Click “Start Firefox” after selecting the profile with which you want to launch Firefox.
11. Set Profile back to “default” (enable you to use your previous settings on your browser).
·       After that go to the location where you have kept the profile, i.e., the location in local hard drive which you have selected while creating the profile.
·       Open prefs.js file in Edit mode.
·       Enter below string in prefs.js file and save
user_pref("general.useragent.override", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16");
·       After that we need to start the Selenium Server by specifying the Profile created for iPhone User Agent. The steps to do that are as below:
1.     Open command prompt.
2.     Navigate to the folder where Selenium Server is kept.
3.     Type the below command to start the Selenium Server with that profile
java -jar selenium-server.jar -firefoxProfileTemplate C:\iPhoneUserProfile

Note: Here you need to specify the profile (the profile created for iPhone User Agent) location also. The above command needs to be executed each time you want to emulate the iPhone in order to test the application.
·       After that the Mozilla Firefox browser will start emulating the iPhone User Agent and you can execute the Selenium Automation Script with iPhone User Agent.
Notes: 
·       In order to go back to the original setup, you just need to stop the running Selenium Server and restart the server as you used to do before. By doing this, you’ll be able to execute Selenium Automation Scripts like how you used to execute earlier.
·       Creation of Firefox profile for iPhone User Agent is just a one-time job. Profile needs to be created again if it gets deleted.

·       Only thing you need to do each time you want to switch between the normal setup and the iPhone User Agent is to stop and re-start the Selenium Server with respective proper command.s

5 comments:


  1. Day by day I am getting new things and learn new concept through your blogs, I am feeling so confidants, and thanks for your informative blog keep your post as updated one...
    PHP Training in Chennai

    ReplyDelete
  2. Thanks for sharing your view to our knowledge’s, its helps me plenty keep sharing…
    JAVA Training Institutes in Chennai

    ReplyDelete
  3. Hi,
    Thanks for sharing the great information... Its useful and helpful information…Keep Sharing.
    Selenium Training In Hyderabad

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete