Taking a Screenshot using Selenium WebDriver in C#

March 18, 2014 5 comments

It is always good to capture the screenshot of the test results if you are running the tests overnight. It is very easy and you may explicitly set the areas were you want to take the screenshot during the execution of automated tests and specify the save location.

SOFTWARE REQUIREMENTS:

  • Windows 7 as OS
  • Microsoft Visual Studio 2010 as IDE
  • NUnit as Unit Testing Tool
  • Selenium as a Test Automation Tool

Let me consider the test:

Given I am on the Google home page
When I search for text selenium
Then I should see the search results

I would be interested to take the snapshot in 2 locations:

  • When the system inputs the search text in the search field
  • Displaying of search results screen
TEST EXECUTION INSTRUCTIONS:
  • Refer my previous blog on Set-up instructions.
  • Copy and paste the code snippet below into your Visual Studio 2010.
  • Run the code using NUnit.
  • Visit the image save location to view the screenshots (ex: C:\Users\anoops\Desktop\Screenshots in my case)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using System.Drawing.Imaging;

namespace TestAutomation
{
 [TestFixture]
 public class Driver
 {
   IWebDriver driver;

   public void TakeScreenshot(IWebDriver driver, string saveLocation)
   {
   ITakesScreenshot ssdriver = driver as ITakesScreenshot;
   Screenshot screenshot = ssdriver.GetScreenshot();
   screenshot.SaveAsFile(saveLocation, ImageFormat.Png);
   }

   [SetUp]
   public void Setup()
   {
   // Create a new instance of the Firefox driver
   driver = new FirefoxDriver();
   }

   [TearDown]
   public void Teardown()
   {
   driver.Quit();
   }

   [Test]
   public void GoogleSearch()
   {
   //Navigate to the site
   driver.Navigate().GoToUrl("http://www.google.com.au");
   // Find the text input element by its name
   IWebElement query = driver.FindElement(By.Name("q"));
   // Enter something to search for
   query.SendKeys("Selenium");
   //Take screenshot during the input of search text
   TakeScreenshot(driver, @"C:\Users\anoops\Desktop\Screenshots\SearchInput.png");
   // Now submit the form
   query.Submit();
   // Google's search is rendered dynamically with JavaScript.
   // Wait for the page to load, timeout after 10 seconds
   WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
   wait.Until((d) => { return d.Title.StartsWith("selenium"); });
   //Check that the Title is what we are expecting
   Assert.AreEqual("selenium - Google Search", driver.Title);
   //Take screenshot after the dispay of search results
   TakeScreenshot(driver, @"C:\Users\anoops\Desktop\Screenshots\SearchResults.png");
  }
 }
}
Advertisements

Data Driven Testing (DDT) using C#, Selenium WebDriver and NUnit

March 10, 2014 6 comments

Data Driven Testing (DDT) is to verify many different test cases by driving the test from an external data source instead of using the same hard-coded values each time the test runs. This way, you can test how the application handles various input without having a lot of similar tests that only have different data sets.

SOFTWARE REQUIREMENTS:

  • Windows 7 as OS
  • Microsoft Visual Studio 2010 as IDE
  • NUnit as Unit Testing Tool
  • Selenium as a Test Automation Tool
  • Microsoft Excel as External Data Source

SET-UP INSTRUCTIONS:

Refer my previous blog on set-up instructions.

TEST SCENARIO:

As an end user,
I would like to visit the google search page 
And then I would like to search an item so that
I can view the search results

TEST EXECUTION INSTRUCTIONS:

  • Create a sample spreadsheet using MS Excel and add some search text that needs to be searched.
  • Copy and paste the code snippet below into your Visual Studio 2010.
  • Add the reference to Microsoft.Office.Interop.Excel using .Net tab in the ‘Add Reference’ window.
  • Update the location of the spreadsheet in the code (i.e., in my case @”C:\Users\anoops\Desktop\GoogleTestData.xls”)
  • Run the tests using NUnit.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
using Excel = Microsoft.Office.Interop.Excel;

namespace TestAutomation
{
 [TestFixture]
 public class Driver
 {
  IWebDriver driver;

  [SetUp]
  public void Setup()
  {
  // Create a new instance of the Firefox driver
  driver = new FirefoxDriver();
  }

  [TearDown]
  public void Teardown()
  {
  driver.Quit();
  }

  [Test]
  public void GoogleSearch()
  {
   Excel.Application xlApp;
   Excel.Workbook xlWorkBook;
   Excel.Worksheet xlWorkSheet;
   Excel.Range range;

   string str;
   int rCnt = 0;
   int cCnt = 0;

   xlApp = new Excel.Application();
   //Opening Excel file
   xlWorkBook = xlApp.Workbooks.Open(@"C:\Users\anoops\Desktop\GoogleTestData.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
   xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);

   //Gives the used cells in the sheet
   range = xlWorkSheet.UsedRange;

   for (rCnt = 1; rCnt <= range.Rows.Count; rCnt++)
   {
    for (cCnt = 1; cCnt <= range.Columns.Count; cCnt++)
     {
      //Get the string from the sheet
      str = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
      driver.Navigate().GoToUrl("http://www.google.com.au");
      // Find the text input element by its name
      IWebElement query = driver.FindElement(By.Name("q"));
      // Convert the search string to lower case
      string lowerstr = str.ToLower();
      // Input the search string
      query.SendKeys(lowerstr);
      // Submit the form
      query.Submit();

      // Google's search is rendered dynamically with JavaScript.
      // Wait for the page to load, timeout after 5 seconds
      WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
      IWebElement title = wait.Until<IWebElement>((d) =>
        {
        return d.FindElement(By.ClassName("ab_button"));
        });

      //Check that the Title is what we are expecting
      Assert.True(driver.Title.ToLower().StartsWith(lowerstr));
      //Assert.True(driver.Title.Contains(lowerstr));
      //Console.WriteLine("Page Title is: " + driver.Title);
       }
      }
   xlWorkBook.Close(true, null, null);
   xlApp.Quit();

  }
 }
}

Test Automation using Java, Selenium WebDriver and TestNG

February 16, 2014 2 comments

SOFTWARE REQUIREMENTS:

  • Windows 7 as OS
  • Eclipse as IDE
  • TestNG as Unit Testing Tool
  • Selenium as a Test Automation Tool

SET-UP INSTRUCTIONS:

Adding the Selenium WebDriver to the project:
  • Download the Selenium WebDriver for Java from the location: http://seleniumhq.org/download/
  • Create a new Java project in Eclipse IDE using File menu: ‘File -> New -> Java Project
  • In Step 1 of Wizard, Add the Project name (say ‘JavaTestAutomation‘ as in my case) and click on the ‘Next‘ button.
  • In Step 2 of Wizard, click on the ‘Libraries‘ tab and then click on ‘Add External JARs‘ button.
  • Add all the Selenium JAR files from the downloaded Selenium WebDriver folder in the ‘JAR Selection‘ window.
  • Finally, click on the ‘Finish‘ button in the Wizard window.
Setting up TestNG with Eclipse:
  • In Eclipse, select ‘Help -> Install New Software…
  • Input the site URL http://beust.com/eclipse in the ‘Work With‘ field and hit the ‘Enter‘ key. ‘TestNG‘ appears in the list.
  • Select ‘TestNG‘ option and click on the ‘Next’ button as in the snapshot.
  • Accept the terms of the license agreement for TestNG and click on the ‘Next‘ button. TestNG plug-in installation progress indicator is displayed.
  • Restart the Eclipse and TestNG plug-in is installed as it appears under the ‘Run‘ toolbar option shown in the snapshot below:

Consider a sample test scenario

As an end user,
I would like to visit the google search page 
And then I would like to search an item so that
I can view the search results

STEPS:

  • In Eclipse, create a new Class file (say ‘GoogleSearch’ in my case) using File -> New -> Class.
  • In ‘New Java Class’ window, set the Name field to ‘GoogleSearch‘ and Package field to ‘googlesearch‘ as in the snapshot below. Click on the ‘Finish‘ button.
  • Define the required packages under the import declaration.
  • Under the @Test attribute, define a constructor to create a new instance of the Firefox driver.
  • Under the @Test attributenavigate to the google search page.
  • Under the @Test attributefind the text input element by its name. Here, the element name for the search field is ‘q’, which is identified using the Firebug (Add-ons for Firefox).
  • Under the @Test attribute, input the search text and hit the Search button.
  • Under the @Test attribute, validate the result using Assert.assertEquals method.

 

TEST EXECUTION INSTRUCTIONS:

  • Copy and paste the code snippet below into Eclipse.
package googlesearch;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.testng.Assert;
import org.testng.annotations.Test;

public class GoogleSearch {

protected WebDriver driver;

@Test
public void googlesearch()
{
// Create a new instance of the Firefox driver
this.driver = new FirefoxDriver();

// Navigate to the site
driver.get("http://www.google.com");

// Find the text input element by its name
WebElement SearchTextBox = driver.findElement(By.name("q"));
WebElement SearchButton = driver.findElement(By.name("btnG"));

// Enter something to search for
SearchTextBox.sendKeys("Selenium");
// Click on the Search button
SearchButton.click();

// Google's search is rendered dynamically with JavaScript
// Wait for the page to load, timeout after 10 seconds
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("selenium");
}
});

// Check that the Title is what we are expecting
Assert.assertEquals(driver.getTitle(), "selenium - Google Search");
driver.quit();
}
}

RUN THE TEST USING TestNG:

  • In Eclipse, Go to Run -> Run As ->  TestNG Test.
  • Test is executed using TestNG and the result will be displayed in TestNG view as shown in the snapshot below.

Test Automation using C#, Selenium WebDriver and NUnit

February 8, 2014 67 comments

SOFTWARE REQUIREMENTS:

  • Windows 7 as OS
  • Microsoft Visual Studio 2010 as IDE
  • NUnit as Unit Testing Tool
  • Selenium as a Test Automation Tool

SET-UP INSTRUCTIONS:

To install the Selenium WebDriver project:
  • Create a new Project with C# Class Library and save it (‘TestAutomation’ in my example).
  • Rename the class ‘Class1.cs’ to ‘Driver.cs’.
  • Download and install NuGet Package Manager using Tools -> Extension Manager. Restart MS Visual Studio in order for the changes to take effect.
  • Go to Package Manager Console install the latest version of Selenium WebDriver by running the command Install-Package Selenium.WebDriver -Version 2.20.0
  • Install the latest version of Selenium WebDriver Support Classes by running the command Install-Package Selenium.Support
 
 
Referencing the NUnit Library:
  • Download the latest NUnit framework from the site: http://www.nunit.org
  • Install the NUnit software on your machine.
  • In Visual Studio, Go to the Project -> Add Reference menu item.
  • When the Add Reference dialog appears, click on ‘Browse’ and navigate to C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\framework and select nunit.framework.dll.
  • Finally, the solution Explorer should look like this:

Consider a sample test scenario:

As an end user,
I would like to visit the google search page 
And then I would like to search an item so that
I can view the search results

Steps:

  • Define the browser on which the tests needs to be executed in [SetUp] attribute.
  • In the [Test] attributenavigate to the google search page.
  • In the [Test] attributefind the text input element by its name. Here, the element name for the search field is ‘q’, which is identified using the Firebug (Add-ons for Firefox).
  • In the [Test] attribute, input the search text and submit the form.
  • In the [Test] attribute, validate the result using Assert method.

TEST EXECUTION INSTRUCTIONS:

  • Copy and paste the code snippet below into your Visual Studio 2010.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

namespace TestAutomation
{
[TestFixture]
 public class Driver
 {
 IWebDriver driver;

[SetUp]
 public void Setup()
 {
 // Create a new instance of the Firefox driver
 driver = new FirefoxDriver();
 }

[TearDown]
 public void Teardown()
 {
 driver.Quit();
 }

[Test]
 public void GoogleSearch()
 {
 //Navigate to the site
 driver.Navigate().GoToUrl("http://www.google.com.au");
 // Find the text input element by its name
 IWebElement query = driver.FindElement(By.Name("q"));
 // Enter something to search for
 query.SendKeys("Selenium");
 // Now submit the form
 query.Submit();
 // Google's search is rendered dynamically with JavaScript.
 // Wait for the page to load, timeout after 5 seconds
 WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
 wait.Until((d) => { return d.Title.StartsWith("selenium"); });
 //Check that the Title is what we are expecting
 Assert.AreEqual("selenium - Google Search", driver.Title);
 }
 }
}
Running the tests using NUnit:
  • In Visual Studio, Go to Projects -> Project Properties (‘TestAutomation Properties’ in my example).
  • Click on the ‘Debug’ tab.
  • Set the ‘Start external program’ to the location of NUnit exe file (C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-x86.exe) as shown in the snapshot below.
  • Build the solution, Go to ‘Build -> Build Solution’ (hit the F6 key) in Visual Studio.
  • Execute the test, Go to ‘Debug -> Start Debugging’ (hit the F5 key) in Visual Studio. Visual Studio invokes the NUnit application.
  • In NUnit, click on ‘File -> Open Project’ and choose the location of the TestAutomation.dll file as shown in the snapshot below.
  • In NUnit, click on the ‘Run’ button to run the tests. Test is executed using NUnit and the result will be displayed in NUnit GUI window as shown in the snapshot below.
 
 

User Stories

October 29, 2013 Leave a comment

Scrum Master, Product Manager, Developers and Testers collaborate to discuss about the requirements. How are requirements communicated?

STEP 1: REQUIREMENTS

Product Manager comes up with the requirements and communicates it in the form of user stories and UI prototypes. User stories generally follow the following template:

As a [role]
I want [feature]
so that [benefit]
 
For example:
As a user,
I want to login to the Gmail online email service by providing my username and password,
so that I can view my personal emails.
 

STEP 2: ELABORATION OF REQUIREMENTS

Tester elaborates the user stories are transforms into the test scenarios in BDD style. BDD generally follow the following template:

Given [context] 
And [some more context]
When [event]
Then [outcome]
 
For example:
Scenario 1:
Given that I am an end user,
And I am in the login screen of the Gmail online email service,
When I input valid username, valid password and click on the ‘Sign In’ button,
Then I should login to my personal mailbox and view my emails.
 
Scenario 2:
Given that I am an end user,
And I am in the login screen of the Gmail online email service,
When I input valid username, invalid password and click on the ‘Sign In’ button,
Then I shouldn’t login to my personal mailbox and system should display an error message “Invalid username/password”.
 
Scenario 3:
Given that I am an end user,
And I am in the login screen of the Gmail online email service,
When I input invalid username, valid password and click on the ‘Sign In’ button,
Then I shouldn’t login to my personal mailbox and system should display an error message “Invalid username/password”.
 
Scenario 4:
Given that I am an end user,
And I am in the login screen of the Gmail online email service,
When I input invalid username, invalid password and click on the ‘Sign In’ button,
Then I shouldn’t login to my personal mailbox and system should display an error message “Invalid username/password”.
 

STEP 3: REVIEW OF REQUIREMENTS

Product Manager reviews the test scenarios written by the testers and moves the user stories to the Estimation board, if he is happy with the test scenarios. If not, Product Manager provides feedback to the tester and the tester needs to update the test scenarios based on the feedback and provide it for the next review. This process continues until the Product Manager is happy with the test scenarios.

STEP 4: ESTIMATION OF REQUIREMENTS

To start an estimating session, the product owner reads a user story and describes a feature to the estimators, who should include team leaders of Development teams, UI Design teams and Testing teams. Each estimator is holding a deck of cards with values like 0, 1, 2, 3, 4 and 5, where the values represent the number of story points. When the feature has been fully discussed, each estimator privately selects one card to represent their estimate. All cards are then revealed at the same time. If all estimators selected the same value, that becomes the estimate. If not, the estimators discuss their estimates. The high and low estimators should especially share their reasons. After further discussion, they come up with the same value. Scrum Master records the stories points for the each areas (i.e., Development, Testing and UI Design) and places the user stories in Product Backlog.

STEP 5: ROLL-OUT OF USER STORIES FOR IMPLEMENTATION

Product Manager discusses with the Business/Customer, priorities the stories for implementation and rolls-out the user stories to the Implementation board.

Why Agile is better than V-Model?

October 28, 2013 3 comments

V-model is a software development model that involves building a logical V shape sequence where the testing techniques associated with the design are reflected as descending and are applied for the “verification” and connected to the requirements or specifications parts are reflected as ascending and are applied for “validation”. Equal weight to coding and testing in the V-model gives software development process. The V-model ordains that the code testing documentation is written in tandem with the development phases that means, for instance, the integration tests should be documented as and when the high level design is finalized and the unit tests should be ready as and when the detailed specifications are laid down.

V-Model

The idea of the V-model is to have a implementation plan for the software testing at each level namely component, interface, system, acceptance and release of the software project which need to be adhered to eliminate discrepancies in the software simultaneously rather than waiting for the software development process to complete before handling it to the software testing professionals.

Agile testing is a software testing practice that follows the rules of the agile manifesto, treating software development as the customer of testing. Agile testing involves testing from the customer perspective as early as possible, testing early and often as code becomes available and stable enough from module/unit level testing. Agile methods were developed as a response to the issues that the traditional V-Model and waterfall methodologies had with defining requirements and delivering a product that turned out to be not what the end user actually wanted and needed.

Agile

Testing from the beginning of the start of the project and continually testing throughout the project life-cycle is the foundation on which agile testing is built. Every practice, technique or method is focused on this one clear goal. Agile methodologies are designed to break the software down into manageable parts that can be delivered earlier to the customer. The aim of any Agile project is to deliver a basic working product as quickly as possible and then to go through a process of continual improvement. An Agile project is characterized by having a large number of short delivery cycles (sprints) and priority is given to the feedback-loops from one cycle to the next. The feedback-loops drive continuous improvement and allow the issues that inevitably occur (including the way requirements have been defined or the quality of the solution provided) to be dealt with much earlier in the development life cycle. To achieve this, companies need to re-think their approach to delivery and have their previously independent contributors (Business Analysts, Developers, Testers, End Users etc.) worked together in teams.

Kanban

The key challenges for a tester on an agile project are:

  • No traditional style business requirements or functional specification documents. We have small story cards developed from the 4×4 inch cards, which only detail one feature. Any additional details about the feature are captured via collaborative meetings and discussions.
  • Testing starts as early as practical and continuously throughout the lifecycle so expect that the code won’t be complete and is probably still being written.
  • Acceptance Test cases are part of the requirements analysis process and are developed before the software is developed.
  • The testing team has a responsibility to create automated unit tests which can be run against the code every time a build is performed.
  • With multiple code deliveries during the iteration, the regression testing requirements have now significantly increased and without test automation support, the ability to maintain a consistent level of regression coverage will significantly decrease.

Why I prefer Agile over V model?

Timeline-VModel
 
 Timeline-Agile

In the phase diagram, it is clear that testing in Waterfall happens at the end, right before release. The diagram is idealistic; because it gives the impression there is as much time for testing as there is for coding. In many projects, this is not the case. The testing gets “squished” because coding takes longer than expected, and because teams get into a code-and-fix cycle at the end.

Agile is iterative and incremental. This means that the testers test each increment of coding as soon as it is finished. Iteration might be as short as one week, or as long as a month. The team builds and tests a little bit of code, making sure it works correctly, and then moves on to next piece that needs to be built. Programmers never get ahead of the testers, because a story is not “done” until it has been tested.

HttpWatch Automation using C# and NUnit

January 17, 2013 Leave a comment

In web application development, web pages require the use of multiple HTTP requests to download HTML, graphics and JavaScript. I came across a tool named HttpWatch that shows what HTTP traffic is triggered when a webpage is accessed. This tool integrates with Internet Explorer and Firefox browsers.  I used to run my tests using this tool manually for every iterations of my testing.

In Agile, the number of test increases with the story points and this indeed increased my test efforts for upcoming iterations. So, I felt that there is a need for automation. This tool supports test automation using C# and Ruby. As I was working on a .Net project, I had to use C# as a programming language for setting up the automation framework.

SOFTWARE REQUIREMENTS:

  • Microsoft Visual Studio 2010 as IDE
  • NUnit as Unit Testing Tool
  • HttpWatch Installed

SET-UP INSTRUCTIONS:

Referencing the HttpWatch Automation Library:
  • Create a new Project with C# Class Library and save it (‘HttpWatchPerformance’ my example).
  • Rename the class as DriverScript.cs.
  • In Visual Studio, Go to the Project -> Add Reference menu item.
  • When the Add Reference dialog appears, click on the COM tab. Find the ‘HttpWatch Automation Library’ in the list and select it as shown in the figure:
 
Referencing the NUnit Library:
  • Download the latest NUnit framework from the site: http://www.nunit.org
  • Install the NUnit software on your machine.
  • In Visual Studio, Go to the Project -> Add Reference menu item.
  • When the Add Reference dialog appears, click on ‘Browse’ and navigate to C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\framework and select nunit.framework.dll.
  • Finally, the solution Explorer should look like this:
 

Now, it’s the time to write tests. Let me explain with a sample test scenario:

As an end user,
I would like to visit the google home page 
And then I would like to click on the 'Sign in' button
so that I can login to Google account

Steps:

  • Define the browser on which the tests needs to be executed in [TestFixtureSetUp] attribute.
  • In the [Test] attribute, clear the log for deleting the old test results and then start recording.
  • In the [Test] attribute, pass the URLs of ‘Google home page’ and ‘ Google Sign In page’ using the 2 variables myURL1 and myURL2 respectively.
  • Specify the location for saving the HttpWatch log file.
  • Refer the APIs available for HttpWatch by visiting the URL link: http://apihelp.httpwatch.com/#Automation Overview.html

TEST EXECUTION INSTRUCTIONS:

  • Copy and paste the code snippet below into your Visual Studio 2010.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit;
using NUnit.Framework;
using HttpWatch;
using SHDocVw;

namespace HttpWatchPerformance
{

 public class PerformanceTests
 {
  private HttpWatch.Controller controller;
  private HttpWatch.Plugin plugin;

 [TestFixtureSetUp]
  public void Setup()
  {
  controller = new HttpWatch.Controller();
  //Creating the HttpWatch plug-in for IE
  plugin = controller.IE.New();
  //Creating the HttpWatch plug-in for Firefox
  //plugin = controller.Firefox.New("");
  }

  public void init()
  {
  }

 [Test]
  public void Test1()
  {
  //Turn Off filtering
  plugin.Log.EnableFilter(false);

  //Clear the HttpWatch Log
  plugin.Clear();

  //Start Recording
  plugin.Record();

  //Loading a Page using HttpWatch
  string myURL1 = "http://www.google.com.au/";
  plugin.GotoURL(myURL1);
  //Validate that Step 1 is executed
  Console.WriteLine("Step 1 executed");
  //Don't return until the page loads
  controller.Wait(plugin,-1);
  string myURL2 = "https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.com.au/";
  plugin.GotoURL(myURL2);
  //Validate that Step 2 is executed
  Console.WriteLine("Step 2 executed");
  //Don't return until the page loads
  controller.Wait(plugin, -1);
  //Save an HttpWatch Log (.hwl) file
  plugin.Log.Save(@"C:\Users\Administrator\Downloads\HttpWatchPerformance\Logs\Test1.hwl");
  }
 }
}
Running the tests using NUnit:
  • In Visual Studio, Go to Projects -> Project Properties (‘HttpWatchPerformance Properties’ in my example).
  • Click on the ‘Debug’ tab.
  • Set the ‘Start external program’ to the location of NUnit exe file (C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-x86.exe) as shown in the snapshot below.
  • Build the solution, Go to ‘Build -> Build Solution’ (hit the F6 key) in Visual Studio.
  • Execute the test, Go to ‘Debug -> Start Debugging’ (hit the F5 key) in Visual Studio. Visual Studio invokes the NUnit application.
  • In NUnit, click on ‘File -> Open Project’ and choose the location of the HttpWatchPerformance.dll file.
  • In NUnit, click on the ‘Run’ button to run the tests. Test will be executed and the results will be saved in the log file, Test1.hwl in the specified location. Refer the log file for the test results as shown in the snapshot below:
 
%d bloggers like this: