Stage 5: Implementing Support for the WebExtBook's Identification Properties

In this section you implement support for retrieving the values of identification properties during a test run. UFT One uses identification property run-time values in different standard test object methods, such as GetROProperty. Identification property run-time values are also required for different basic capabilities, such as creating checkpoints and outputting values.

To support retrieving the run-time values of identification properties, you need to implement a JavaScript function that accepts a PropertyName parameter and returns the value of any property UFT One requests. You must implement this method to return a value for each identification property defined in the test object configuration file.

In the toolkit configuration file, you can specify the JavaScript file in which you implemented the JavaScript function that retrieves property values. You can also specify the name of the function that you implemented for this purpose. However, if you do not specify a function name, UFT One calls get_property_value (PropertyName) and this is the function that you must implement. If you do not specify a file name, UFT One calls the function from the JavaScript file you specified in the Control\Settings element. Therefore, in this lesson, you create the get_property_value function in the WebExtBook.js file.

To support retrieving the run-time values of the WebExtBook's identification properties:

Add the following lines to the WebExtBook.js file:

// Property retrieval implementation
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The function provides values for all of the identification 
// properties defined in the test object configuration XML file.
function get_property_value(prop) 
{
    if ( prop == "title" )
    // For the "title" identification property, 
    // Return the inner text of the second cell in the first row
    {    
        return _elem.rows[0].cells[1].innerText;
    }
    if ( prop == "authors" )
    // To return a list of all the authors, look for all the 
    // children of the first cell in the second row.
    {
        var BookAuthors = "";
        var AuthorsCount = 0;
        for( var i = 0 ; i < _elem.rows[1].cells[0].children.length ; ++i )
        {
            if( _elem.rows[1].cells[0].children[i].tagName == "A" )
          {
                if( AuthorsCount > 0 )
                    BookAuthors += ",";
                    BookAuthors += _elem.rows[1].cells[0].children[i].innerText;
                    AuthorsCount++;
            }
        }
          return BookAuthors;
    }
    if ( prop == "price" )
    // To return the price of the book, return the innerText 
    // property of the first cell in the fourth row.
    {
        return _elem.rows[3].cells[0].children[0].innerText;
    }
     if ( prop == "min_used_price" )
    // To return the lowest price available for a used copy of the
    //  book, return the innerText property of the second child of 
    // the first cell in the fourth row.
    {
        if( _elem.rows[3].cells[0].children.length > 2 )
            return _elem.rows[3].cells[0].children[2].innerText;
    }
}

Note: You can modify the WebExtBook.js file in the toolkit support set folder and then later deploy it to UFT One for testing, or you can modify <UFT_One_installdir>\dat\Extensibility\Web\Toolkits\WebExtSample\WebExtBook.js directly.

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