Wednesday, 28 October 2009

Using Non-Functional Tests Tools with Axe and WatiN

As a functional automation tester have you ever been asked the following questions:

  • From Infrastructure - We have upgraded the network and are expecting an increase in throughput. Can you please run a quick test and let us know the improvement stats?
  • From a Developer – We have made some changes to the framework and are expecting some issues. Can you please run some tests and let us know the error codes?

I was faced with the second question, and after a bit of googling and discussions with the Dev team I found out about HttpWatch:

A quick read of their website gave me this:

“All web applications make extensive use of the HTTP protocol (or HTTPS for secure sites). Even simple web pages require the use of multiple HTTP requests to download HTML, graphics and javascript. The ability to view the HTTP interaction between the browser and web site is crucial to these areas of web development”

If you want to investigate more about the features that HttpWatch provides, go here:

A cool thing about HttpWatch is that it has a COM based automation interface, which allows you to use it from C#, as well as Javascript and Ruby. This means that I could integrate it into Axe, a bit more googling gave me this which formed the basis for the integration of HttpWatch and Axe:

Using HttpWatch with WatiN:

The steps to integrate HttpWatch into Axe are as follows, or you can just download the sample Axe project, install HttpWatch and get testing:

1.Axe and WatiN installed and configured.
2.A WatiN project with a local Action Map and custom library file.
3.Download and install the free Basic Edition of HttpWatch.
4.Add two methods to the custom project library file.
5.Modify the local Action Map and Run config files.

The output from HttpWatch is a hwl.file per Axe test, so if you have 100 Axe tests, you will get a 100 hwl.files. Not a good thing, when you are pressed for time. To minimise the time spent pouring over the output files you should create a test run that exercises most pages, and add a switch to the Run config file to turn the HttpWatch logging on or off.

Installing HttpWatch

I downloaded the free Basic Edition of HttpWatch (, version 6.2.10 and installed it using the default options. A HttpWatch folder was created in my ProgramFiles folder on the C drive.

Adding Methods to the Project Library File

If you do not have a custom project library file, see the Axe documentation for creating one.

The first step is to add a reference to HttpWatch to your custom library project.


We are going to add two methods to the Project Library file called:

  • InitialiseHttpWatch(), and
  • CloseHttpWatch()
public static HttpWatch.Plugin InitialiseHttpWatch(Browser ie, AxeMainAPI axe)


// HttpWatch
if (String.Compare(axe.GetRunCategoryOption("Option", "HttpWatch"), "TRUE", true) == 0)
// Attach HttpWatch to instance of IE
HttpWatch.Controller ct = new HttpWatch.Controller();
HttpWatch.Plugin plugin = ct.IE.Attach((SHDocVw.IWebBrowser2)ie.IE.InternetExplorer);

// Start recording a log file in HttpWatch

return plugin;
return null;

public static void CloseHttpWatch(HttpWatch.Plugin plugin, string resultDir, string testID)
if (plugin != null)
plugin.Log.Save(resultDir + @"\" + testID + ".hwl");
HttpWatch.Summary logSummary = plugin.Log.Entries.Summary;

There are two variables in the CloseHttpWatch() method , testID and resultDir that need to be declared and set. This is done in the __testPrefix section of the Local Action Map.

Modify the Run Config File

Add the following switch to the Run config file and set it to False:

This is where you turn on the HttpWatch logging. The code looks for a value of TRUE to start logging, any other value and the logging will be turned off.

Modify the Local Action Map

Add the following to the __testPrefix section of the Local Action Map:
// Run settings
string testID = "%TESTID%";
string resultDir = @"%RESULTDIR%";
HttpWatch.Plugin plugin = null;

Modify the testEnd(id) section of the Local Action Map to look like the following:

catch(Exception ex)
NovaTest.NovaTestLib.CloseHttpWatch(plugin, resultDir, testID);
if(ie.IE != null) ie.IE.Dispose();

You should now be able to Build and Run your Axe project and view the HttpWatch output in the Results directory.

Integrating HttpWatch into Axe does not make Axe a performance test tool, but it does give you some extra ammo in the hunt for bugs.

Happy testing

Marc Maurhofer

Senior Test Automation Analyst

Support Files

Users must extract the zip file to c:\nfocushttpwatch because some paths are hardcoded for expediency.

Versions of software for reference:
Axe : 2.0.3
Watin : 1.3 (.NET 2.0)
HttpWatch Basic : 6.2.10

No comments: