Watir Script Generation (WSG) Internet Explorer Plug-in

This project started as a take-home assignment from a company which is consider hiring me. Unfortunately I did not get the position because my design was too complex that I did not get to finish it in time. But I intend to finish implementing this project and will post the progress, documentation, and result on this site.

General Requirement:

  • Design and build a useful Internet Explorer plug-in to record the user actions and turn it to a Watir test script.

Detailed Requirement:

  • Create an Internet Explorer Plug-in that has a tool bar that looks like Webmetric’s Script Recorder but I will implement just two buttons: Start and STOP buttons.

  • When the START button is clicked, all user actions will start being recorded.
  • When the STOP button is clicked, the recording will stop. And a window will pop up with where the script has been saved to.
  • Limitation
    • The recording will always be saved to the same file called “MyRecording.rb”.

Required Development Tools and Libraries:

  • Ruby
  • Watir
  • Asynchronous Pluggable Protocol
  • Web Browser Control
  • ArrayList Data Container
  • Windows Template Library
  • ATL
  • Visual Studio 2008 (90-days trial version)
  • Windows Platform SDK

Estimated Time for Completion:

  • 24 hours ( already spent 12 hours; the implementation should take about 12 hours)

Time Already Spent to Overcome Learning Curve:

  • Set up and Get Familiarized with the Development Environment (3 hours):
    • Downloaded, installed, and got acquainted with Visual Studio 2008. Obtained sample VC++ projects from Microsoft site and get most of them to build on my Windows XP machine
    • Downloaded and installed the Ruby and Watir test environment. Studied several Watir scripts from Watir and OpenQA sites.
  • Learned How to Create a New Protocol, Register it, and Create Protocol Handlers, using Asynchronous Pluggable Protocols (3 hours)
  • Learned How to Create and Add a Custom Toolbar to IE (2 hour)
  • Learned How to Catch the User Clicking Events When Users Click a Link or Enter a new URL( 2 hours)
    • Read WebBrowser Control page on event handling
    • Searched for and found a sample project. This sample project demonstrates how to catch when users hit the refresh button. Got the sample project to build.
    • Study this sample project (Steven Fox’s “Detecting the IE Refresh button using IWebBrowser2 and DWebBrowserEvents2 events“) and took notes of relevant codes to be used in WSG project.
    • Modified the sample project so that the new link events are caught, instead of the refresh events. Of course, the ideal is to catch all events, but I’d like to keep it simple for now.
  • Created a preliminary design for WSG plug-in after overcoming the learning curve (2 hour)

Essential Classes in Preliminary Design:

  • Watir Script Writer:
    • This class will handle writing and saving a valid Watir script
  • Watir Script Executor:
    • This class will handle executing a Watir script. It will also handle invalid scripts.
  • IE Content Events Handler
    • This class will handle events fired when users click links on the pages or when they enter a new URL in the address field
  • WSG Toolbar Events Handler
    • This class will handle events fired when users click buttons in the WSG toolbar to start or stop the recording

References and Sample Code:

  1. Watir site
  2. MSDN’s Internet Explorer Development reference page
  3. Asynchronous Pluggable Protocols reference page from MSDN
  4. Prafulla Tekawade’s “RSS Reader Plug-in for Internet Explorer” project from The Code Project site
  5. David M Brooks’ “Custom Hyperlinks Using Asynchronous Pluggable Protocols” project from The Code Project site
  6. Steven Fox’s “Detecting the IE Refresh button using IWebBrowser2 and DWebBrowserEvents2 events” project from The Code Project site

Best Practice for Creating Dlls from Windows Hardware Developer Central