Web Add-in Extensibility Developer Guide > Tutorial: Learning to Create Web Custom Toolkit Support > Learning to Create UFT Support for a Complex Custom Web Control > Developing the Toolkit Support Set > Stage 6: Implementing Support for Recording on the UsedBooks Control

Stage 6: Implementing Support for Recording on the UsedBooks Control

In this section, you implement support for recording on the UsedBooks control.

  1. In the WebExtSample.xml file, and the following Record element within the Control element that defines the WebExtUsedBooks class:

        <EventListening use_default_event_handling_for_children="false" 
                        type="javascript" function="ListenToEvents"/>

    This instructs UFT not to use the default Web Event Configuration to record events on the UsedBooks control, but to call the ListenToEvents JavaScript function instead.

    In the WebExtUsedBooks.js file add the ListenToEvents JavaScript function:

    function ListenToEvents( elem )
        // Connect to the "Select" event: 
        //When "Select" is clicked, call OnSelectUsedBooksClicked.
        _util.RegisterForEvent(_elem.children[2], "onclick", "OnSelectUsedBooksClicked" );
        return true;

    This function registers UFT to listen to clicks on the Select link, and call the appropriate event handler when the event occurs.

  2. In the WebExtUsedBooks.js file add the OnSelectUsedBooksClicked event handling JavaScript function:

    function OnSelectUsedBooksClicked( handlerParam , eventObj )
        var arr = new Array();
        var booksCount = BookCount();
        // Find the index of the selected radio button and record 
        // a step that runs the SelectBook test object method 
        // with that index.
        var BookIndex = -1;
        for( var i = 0 ; i < booksCount ; i++ )
            if( _elem.rows[2+i].cells[0].children[0].status == true )
                // This is the selected item
                arr[0] = i+1;
                _util.Record( "SelectBook", toSafeArray(arr) , 0 );
                _util.LogLine("SelectBook Recorded",1);
        return true;

    This function checks which book's radio button is selected, and instructs UFT to record a step selecting that book (and add the relevant log message to the event log).

To complete this stage, perform the procedures in Deploying and Testing the Toolkit Support Set (for Stage 6)