HttpWatch Automation Reference - Version 13.x
Using HttpWatch Automation with Ruby / Ruby - Overview
In This Topic
    Ruby - Overview
    In This Topic


    You can install the Ruby language runtime using the installer at .

    Accessing HttpWatch from Ruby

    The HttpWatch automation library is packaged as a COM component. To access it from Ruby you will need to use WIN32OLE::new from the win32ole library. It can be referenced by adding the following require statement to your Ruby source file:

    Using the WIN32OLE library
    Copy Code
    require 'win32ole'

    Communicating with the HttpWatch Extension

    You can only directly create an instance of one class in the library - the Controller class.

    All communication with the HttpWatch extension stems from this class, so the first step is to create an instance of it:


    Creating the Controller
    Copy Code
    # Controller is the only creatable class in the HttpWatch automation interface
    controller ='HttpWatch.Controller')


    Having created a Controller object, the next step is to create an instance of the extension and attach it to a browser instance. The exact code depends on whether you are using Internet Explorer or Google Chrome, but the principles are the same in either case. The Controller object has a property named IE. This property returns a reference to the IE object.

    The IE objects offer two methods, New and Attach. The New method creates a new instance of the IE browser with an HttpWatch extension embedded within it. Attach allows the user to create an HttpWatch extension and embed it in a browser instance that has already been created by some other component. Both methods return a reference to the Plugin object that represents the HttpWatch extension.

    The following code creates a new instance of Internet Explorer with an embedded HttpWatch extension component:

    Creating the HttpWatch extension for IE
    Copy Code
    controller ='HttpWatch.Controller')
    plugin = controller.IE.New()

    Instances of Internet Explorer are referenced through the IE IWebBrowser2 interface, so the IE object's version of the Attach method takes an IWebBrowser2 reference:

    Attach HttpWatch to existing instance of IE
    Copy Code
    # You could have previously created your own instance of IE
    # directly or using an automation framework
    ieBrowser ='InternetExplorer.Application') 
    ieBrowser.Visible = true    # Required to see the new window
     . . .
    control ='HttpWatch.Controller')
    plugin = controller.IE.Attach(ieBrowser) 


    The following code creates a new instance of a Chrome tab with an attached HttpWatch plugin object:

    Creating the HttpWatch extension for Chrome
    Copy Code
    controller ='HttpWatch.Controller')
    plugin = controller.Chrome.New()

    For Microsoft Edge using the Edge property of the controller instead.

    All of these code fragments return a reference to a Plugin object, through which the HttpWatch extension can be controlled.


    See Also