Click here to Skip to main content
13,403,870 members (46,453 online)
Click here to Skip to main content
Add your own
alternative version


54 bookmarked
Posted 16 Aug 2005

Web Replay 2 - Automated Web Testing

, 5 Sep 2005
Rate this:
Please Sign up or sign in to vote.
This article presents an automated software testing tool for web applications (Internet/Intranet) based on Internet Explorer.


Web Replay 2 is an automated software testing tool for Web applications. It helps in detecting bugs and regressions in web applications by replaying scenarios to test the application. Using Web Replay 2, you can automatically navigate to a web page, fill in form fields, click on the Submit (OK) button, and then continue to another web page. To use Web Replay 2, build a JavaScript Scenario File (see below), type the name of the file in the edit box and click on the Replay button.


Web Replay 2 is based on Microsoft's Internet Explorer 6.0, DHTML behaviors and JavaScript (unlike Web Replay 1 that was implemented in C++/COM).

Web Replay 2 uses a FRAMESET with a DHTML behavior attached to the onload event of the bottom frame to execute some JavaScript code to play back a scenario. It's implemented in script only (client-side JavaScript running in Internet Explorer and server-side JavaScript running in ASP pages).

As a consequence, Web Replay 2 gives you full access to the Microsoft Internet Explorer Document Object Model (DOM) within your scenario files. And since the scenario is a JavaScript program, you can implement virtually any test case.

Using the function WebReplay_Navigate(), you can call the server-side code to implement pre-conditions and post-conditions on your test cases (e.g. setting up a database or checking whether the created/modified records are correct).

Using the code

Web Replay provides the following features:

  • Replay scenarios from a JavaScript file.
  • Support every feature supported by Microsoft Internet Explorer (includes Windows Integrated Authentication).
  • Support HTML forms, HTML input elements, HTML hyperlinks (anchors).
  • Support any action on HTML elements available in JavaScript (changing value, raising events, etc...).
  • Support unnamed HTML elements: elements can be found with their associated value and/or innerText and/or HREF (an HTML element can be found based on the value of ANY attribute).
  • Support dynamically-generated Web Sites (client-side): If your web site generates HTML within the browser (using JavaScript's commands like "document.write"), Web Replay 2 can still play back a given scenario - it uses a timeout mecanism to find the dynamically-generated controls.
  • Detect HTTP errors and/or Application errors based on JavaScript regular expression pattern matching.
  • Support simple dialog boxes ("alert" and "confirm" methods). Web Replay overrides the window.alert and window.confirm methods with custom implementations which handles scenario playback.
  • Replay scenarios for servers on the same domain only (the tested web site must be on the same domain as the Web Replay application). This is due to a security limitation in Internet Explorer (cross-site scripting). For more on this limitation, please refer to the following MSDN articles:

A JavaScript scenario file consists of a definition of a function named WebReplayScenario(); it looks like this:

function WebReplayScenario()
  switch (gintState)
    case 0:
      // Open a web page (LOCALHOST only due 
      // to cross-site scripting limitations)
      <A href="" target=_blank>WebReplay_Navigate</A>(

    case 1:
      // Type in some text in a form field
      <A href="" target=_blank>WebReplay_SimulateTextInput</A>("Text1", "NewValue1");

    case 2:
      // Submit form by clicking on a submit button
      <A href="" target=_blank>WebReplay_SimulateHTMLElementClick</A>("OK");

      // Automatically exit from scenario
      <A href="" target=_blank>WebReplay_SetStateNext</A>(-1);

This function implements a state-machine based on the global variable gintState; every time the requested action is successful (e.g. clicking on a button), the state is increased by 1 (state starts at 0). The state is set to -1 when the scenario is finished. In case of any error, the state is set to -2.

The utility function WebReplayScenarioAuto() can ease the process of building scenario - its input is a simple array of states (the state-machine is already implemented - no need to manage the switch and state numbers):

function WebReplayScenario()
   <A href="" target=_blank>WebReplayScenarioAuto</A>(
       // State 1: Navigate to the test Page 
       // (uses an anonymous function definition)
       [ null, function () { <A href="" target=_blank>
          "http://localhost/WebReplay2/WebReplay2Scenario1_step1.asp") }], 

       // State 2: Type in some text in a form field named Text1
       [ "Text1", "NewValue1" ], 

       // State 3: Submit form by clicking on a submit button named "OK"
       [ "OK" ], 

       // State 4: Type in some text in a form field named Text21
       [ "Text1", "NewValue2" ], 

       // State 5: Submit form by clicking on a submit button named "OK"
       [ "OK" ], 

       // State 6: Wait for next page's title: 
       // <h2>Form Submit Debugger</h2>
       // Set state to -1 (end) when the control is found.
       [ null, function () { <A href="" target=_blank>
            WebReplay_WaitForHTMLControl</A>("h2", "innerText", 
                                         "Form Submit Debugger", -1) } ]


A complete JavaScript SDK is available to build the scenario files; and of course, you can extend the SDK with your own JavaScript code...

To build a scenario file, you need to basically know the names (or ids) of the HTML elements within your web application (using the function WebReplay_FindHTMLControlWithName). Alternatively, you can use the content (text) of a control to interact with it (using functions WebReplay_FindAnchorWithText, WebReplay_FindButtonWithText, or WebReplay_FindHTMLControlFromText).

You can interact with the HTML controls using these three functions:

Points of interest

Although it's a complete re-write (v2.1 has nothing to do with Web Replay v1.0), the TODO list is still long.

Web Replay 2 TODO list

  1. Automated recording of scenario files.
  2. Play scenarios multiple times (even infinite loops to stress-test your web application).
  3. Batch playback of scenario files.
  4. Support authentication (NTLM, basic, https) and multiple login accounts.
  5. Support FRAMES (multi-frame documents) or top-FRAME web sites. Some web sites, like CodeProject, use a piece of JavaScript to make sure that they are viewed within a top-level frame; Web Replay 2 is incompatible with those sites...
  6. Use event log file (csv format?) for errors/tracing/debugging.
  7. Support complex dialog boxes (based on methods, window.showModalDialog and/or window.showModelessDialog).


  • 2005-08-19, 08:09:13 +0200 (ven., 19 août 2005) - V2.1.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Emmanuel Kartmann
Web Developer
France France
Fell into computer software at the age of 11, founder of 3 startups, and now manager of an independent software vendor (ISV) labelled proSDK ( And still a freeware writer and technical article author!

You may also be interested in...


Comments and Discussions

QuestionJavascript enabled? Pin
Gabriel_Davini18-Oct-07 11:18
memberGabriel_Davini18-Oct-07 11:18 
AnswerRe: Javascript enabled? Pin
Emmanuel Kartmann18-Oct-07 11:32
memberEmmanuel Kartmann18-Oct-07 11:32 
QuestionRecord? Pin
otrack19-Jun-07 7:04
memberotrack19-Jun-07 7:04 
QuestionDomain? Pin
sides_dale4-Nov-06 8:31
membersides_dale4-Nov-06 8:31 
GeneralMaybe IIS is not installed Pin
Emmanuel Kartmann24-Oct-05 20:21
memberEmmanuel Kartmann24-Oct-05 20:21 
GeneralRe: Maybe IIS is not installed Pin
claudiuo25-Oct-05 11:48
memberclaudiuo25-Oct-05 11:48 
GeneralError when installing on Windows XP Pin
claudiuo24-Oct-05 13:22
memberclaudiuo24-Oct-05 13:22 
GeneralCan't Install on Win 98 SE Pin
EL Raj4-Oct-05 19:07
memberEL Raj4-Oct-05 19:07 
GeneralBug in setup - please download new version Pin
Emmanuel Kartmann5-Sep-05 4:22
memberEmmanuel Kartmann5-Sep-05 4:22 
GeneralPopup Dialog Causing Problems Pin
Jefferson Alan24-Aug-05 13:43
memberJefferson Alan24-Aug-05 13:43 
GeneralRe: Popup Dialog Causing Problems Pin
Emmanuel Kartmann2-Sep-05 0:11
memberEmmanuel Kartmann2-Sep-05 0:11 
Generalseems good Pin
volkan.ozcelik23-Aug-05 23:00
membervolkan.ozcelik23-Aug-05 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.1802120.2 | Last Updated 5 Sep 2005
Article Copyright 2005 by Emmanuel Kartmann
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid