Monday, May 20, 2013

NUnit Documentation

    1. Installing NUnitAsp requires only a few steps
      1. Download and unzip NUnitAsp.
        1. You've probably already done this step, but if not, read on.
        2. NUnitAsp may be downloaded from the NUnitAsp home page, nunitasp.sourceforge.net.
        3. Unzip the NUnitAsp package into a directory of your choice, such as "C:\Program Files\NUnitAsp"
      2. Install NUnit.
        1. You can use any testing tool, but NUnit is the most common.
        2. NUnit may be downloaded from nunit.org.
      3. Reference NUnitAsp in your test projects.
        1. Copy bin\NUnitAdapter.cs into your test project. (This file isn't required, but it makes working with NUnit easier.)
        2. Add bin\nunitasp.dll as a reference.
        3. See the Quick-Start Guide and Tutorial for more information. 
Steps To Work With NUnit

  1. Install Download NUnit which is an open source.
  1. Install Nuint in your system
  1. Add References in Website we need to test
C:\Program Files\NUnit 2.5.2\bin\net-2.0\framework
i.e. nunit.framework.dll
nunit.mock.dll
nunit.framework.dll

4) Add Class file to your App_Code (same directory of class file which you want to test).
  1. Create your own test cases in that class file.


    6.Publish your website and store all assembly in a folder outside the root directory
7. Create a config file for your Assembly (e.g. if your assembly name is App_Code.dll
then its config file should be App_Code.dll.config)

How selenium Run through NUnit:

    1. Open NUnit IDE through start menu.
      1. Go to File > Open Project
      1. Navigate to the directory where your dll is saved
      1. Add Assembly to NUnit. (e.g. App_Code.dll)
      1. Click on Run and the test cases will run
The test cases will run now and if the status will be failed then there will be a red bar and if Status is
Passed then there will be a green bar.

Result Evaluation

Result can be analyzed from result status bar.
When Script is passed the status Bar is green and number of passed script are shown (as shown below).


When the script is failed then the status bar id Red number of passed script as well.

Test result will also store in xml form in the same directory where your dll is and it is shown.

Special Note:

  1. As NUnit does not recognize Global.asax , So we have to add [SetUp] method, this method will be called before each test method in the derived class so mention all that things we need to initialize before running the test cases

  1. It also doesn’t recognize Web.config. So we have to create a separate config file for your dll (if your dll is App_Code.dll then your config should be App_Code.dll.config and it should be in the same directory where your dll is)

  1. We are not running the test cases in web environment , so we cannot access Session variable

    How to execute Selected test cases with NUnit:


    1. Open NUnit and select File >> Open

    1. Navigate the search folder where our selenium project is kept.

    1. Then double click on project .

    1. Go to bin folder and again double click here.

    1. Go to debug folder and again double click here.

    1. Here select project name dll file and click on it and then press open button of pop-up.

    1. Right click on header line and select collapse of location. Please see screen shot below.

      9) Click on + sign button and then all test fixture is open.

      10) Select desire test case which we want to execute, Click on + sign button   regarding same test case.

      11) Select different test scripts with the help oh check box. Here we select many test scripts through checkbox according to scripts.

      12) Go to Test menu and click on Run All or press F5 button.For this only desire test scripts are execute and it gives only result which we want.

      How selenium project execute through NUnit:

      1. Go to selenium project location means where keep selenium project.

      1. Double Click on selenium project .

      1. Click on visual studio file which name is same as project name.

      1. Open Solution Explorer.

      1. Click on App.config file

      1. we want to execute this project.

      1. Click save button from the top save button menu bar.

      1. Click on Build button from the Build menu bar.

      10) Then Open NUnit and select File >> Open

      11) Navigate the search folder where our selenium project is kept.

      12) Then double click on project .

      13) Go to bin folder and again double click here.

      14) Go to debug folder and again double click here.

      15) Here select project name dll file and click and then press open button of pop-up.


        1. After full test run we go click on Tools menu and again click save results as XML

          1. We give here desire location where we want to save this result.

          1. This result in XML format.

          1. Open this result and analyze pass and failure test cases with description.

Wednesday, May 8, 2013

Selenium User Guide


Selenium User Guide

Prerequisites:
  1. Selenium IDE : This is a Mozilla Firefox’s addon and can be downloaded from http://release.seleniumhq.org/selenium-ide/1.0.10/selenium-ide-1.0.10.xpi . An addon will ask permission for installation. Follow the steps and restart firefox. Now Selenium IDE is installed and can be accessed through Mozilla Firefox > Tools > Selenium IDE.(Note: The provided link should be opened only through Mozilla Firefox Browser)
  2. SeleniumRCServer: This can be downloadedhttp://selenium.googlecode.com/files/selenium-remote-control-1.0.3.zip .
  3. Nunit:Thiscanbedownloadedfromhttp://launchpad.net/nunitv2/2.5/2.5.9/+download/NUnit-2.5.9.10348.msi .
  4. Microsoft Visual Studio
  5. JRE 1.5 or later

Test Script types in Selenium:

  1. Basic tabular scripts.
  2. Advanced scripts.

Basic tabular scripts

The scripts recorded by Selenium IDE are initially in this format. These scripts are in the tabular format and run by Selenium IDE itself.


Advanced scripts


These scripts are programming language specific. And can run through Nunit + RC Server.

Steps to run Basic Scripts
  1. Start Selenium IDE.
  2. Go to File > Open (Navigate to the location where basic scripts are available)
  3. Select the script(the script will be selected to run)
  4. Click the PLAY button and the script will run.

    Result Evaluation

    Result can be analyzed from result status bar. If script is passed then Failure=0 and Run = 1 (in case one test script is run at a time). If script is passed then Failure=1 and Run = 0.

    Steps to run Advanced scripts


    1. Download and install Nunit, JRE 1.5 or later, Visual Studio and Mozilla Firefox.
    2. Download Selenium RC server.
    3. Configure dot net client drivers (as specified below)
    4. Copy and paste the advanced script into the class1 created in Visual studio in step 3.
    5. Click f6 to Build.
    6. Now open command prompt.
    7. Navigate to the location where Selenium RC is downloaded.
    e.g. if it is located in ‘E’ drive then go to: “E:\selenium-remote-control-1.0.3\selenium-server-1.0.3”
    1. In the command prompt run the command. “java -jar selenium-server.jar”. (Don’t close the command prompt)
    2. Open Nunit.
    3. Go to File > Open Project
    4. Navigate to the Visual Studio 2008 > Projects > Selenium Project > Selenium Project > Bin > Debug.
    5. Select Selenium Project.dll.
    6. In Nunit click ‘Run’.
    The script will run now in 2 Mozilla Firefox browsers and if the status will be failed then there will be a red bar in Nunit and if status will be passed then the bar will be green.
    Among two browsers one will display the log and other will execute the script in GUI format.
    The browsers will be automatically closed when the test case is completed.

    .NET client driver configuration

    .NET client Driver can be used with Microsoft Visual Studio. To configure it with Visual Studio do as Following.
    1. Launch Visual Studio and navigate to File > New > Project.
    2. Select Visual C# > Class Library > Name your project > Click on OK button.
    3. A Class (.cs) is created. Rename it as appropriate.Under right hand pane of Solution Explorer right click on References > Add References.
    4. Select following dll files - nmock.dll, nunit.core.dll, nunit.framework.dll,ThoughtWorks. Selenium.Core.dll, ThoughtWorks.Selenium.IntegrationTests.dll, ThoughtWorks.Selenium.UnitTests.dll and click on Ok button.



Friday, May 3, 2013

Selenium Introduction


What is Selenium?

Selenium is a open source automated testing tool for web applications across different browsers and platforms. It is using that Selenium focuses on automating web-based applications.
Selenium is not just a single tool but have a suite of softwares, It has four components.

  • Selenium Integrated Development Environment (IDE)
  • Selenium Remote Control (RC)
  • WebDriver
  • Selenium Grid


Birth of Selenium Core


Primarily, Selenium was created by Jason Huggins in 2004. , he was working on a web application that required frequent testing. Having realized that the repetitious manual testing of their application was becoming more and more inefficient, he created a JavaScript program that would automatically control the browser’s actions. He named this program as the “JavaScriptTestRunner.”

Birth of Selenium Remote Control (Selenium RC)


Testers using Selenium Core had to install the whole application under test and the web server on their own local computers, because have the some restrictions by the same origin policy. So , Paul Hammant, decided to create a server that will act as an HTTP proxy to “trick” the browser into believing that Selenium Core and the web application being tested come from the same domain. This system is known as the Selenium Remote Control .

Birth of Selenium Grid


Selenium Grid was developed by Patrick Lightbody to address the need of minimizing test execution times as much as possible. He initially called the system “Hosted QA.” It was capable of capturing browser screenshots during significant stages, and also of sending out Selenium commands to different machines simultaneously.


Birth of Selenium IDE



Selenium IDE, a Firefox extension that can automate the browser through a record-and-playback feature. He came up with this idea to further increase the speed in creating test cases.


Birth of WebDriver:



Simon Stewart created WebDriver , when browsers and web applications were becoming more powerful and more restrictive with JavaScript programs like Selenium Core.
It was the first cross-platform testing framework that could control the browser from the OS level.


Brief Introduction Selenium IDE

Selenium Integrated Development Environment (IDE) is the simplest framework in the Selenium suite and is the easiest one to learn. It is a Firefox plugin that you can install as easily as you can with other plugins. However, because of its simplicity, Selenium IDE should only be used as a prototyping tool. If you want to create more advanced test cases, you will need to use either Selenium RC or WebDriver.

Brief Introduction Selenium Remote Control (Selenium RC)
Selenium RC was the flagship testing framework of the whole Selenium project for a long time. This is the first automated web testing tool that allowed users to use a programming language they prefer.As of version 2.25.0, RC can support the following programming languages:
  • Java
  • C#
  • PHP
  • Python
  • Perl
  • Ruby

Brief Introduction WebDriver



The WebDriver proves itself to be better than both Selenium IDE and Selenium RC in many aspects. It implements a more modern and stable approach in automating the browser’s actions. WebDriver, unlike Selenium RC, does not rely on JavaScript for automation. It controls the browser by directly communicating to it.
The supported languages are the same as those in Selenium RC.
  • Java
  • C#
  • PHP
  • Python
  • Perl
  • Ruby

Selenium Grid


Selenium Grid is a tool used together with Selenium RC to run parallel tests across different machines and different browsers all at the same time. Parallel execution means running multiple tests at once.

Features:
  • Enables simultaneous running of tests in multiple browsers and environments.
  • Saves timeenormously.
  • Utilizes the hub-and-nodes concept. The hub acts as a central source of Selenium commands to each node connected to it.