Planning Support for the Web Add-in Extensibility Sample UsedBooks Control

In this section, you analyze how UFT One currently recognizes the UsedBooks control versus the way it should recognize it, based on your knowledge of the control. Next, you determine the answers to the questions in Understanding the Web Add-in Extensibility Planning Checklist, and fill in the Web Add-in Extensibility Planning Checklist, accordingly.

The best way to do this is to analyze the UsedBooks control from a UFT One perspective on the one hand using the Object Spy, Keyword View, and Record option, and on the other hand, to consider how the control is implemented and the purposes for which it is used.

  1. Open UFT One and Run the UsedBooks control.

    Open UFT One and load the Web Add-in.

    Close any open instances of the UsedBooks control and open it by opening the %ALLUSERSPROFILE%\Documents\ExtAccTool\Samples\WebExtSample\Application\Book.htm file and then clicking Used in the Book control that opens.

  2. Use the Object Spy to view the UsedBooks test object operations.

    In UFT One, open a GUI test and select Tools > Object Spy or click the Object Spy toolbar button to open the Object Spy dialog box. Click the Operations tab and select Test Object Operations.

    In the Object Spy dialog box, click the pointing hand , then click the UsedBooks table.

    The UsedBooks control contains a Web table, for which UFT One support is built in, therefore it recognizes the control as a WebTable, named according to the title of the table. The icon used for the test object is the standard WebTable class icon. UFT One ignores the div element, which is actually the root of the UsedBooks control.

    Close the Object Spy.

  3. Record operations on the UsedBooks control.

    In UFT One, select Run > Run Settings or Record > Record Settings to open the Record and Run Settings dialog box. In the Web tab, select Record and run test on any open browser. Click OK.

    Click the Record button or select Record > Record. In the UsedBooks table, select one of the radio buttons and then click Select.

    With each click, a new step is added to the test:

    Click the Stop button or select Record > Stop to end the recording session.

    The recorded steps reflect the selection of the radio button and the clicking of the link separately, and do not recognize these operations as related to the UsedBooks control.

  4. Determine the custom toolkit to which the UsedBooks control belongs.

    When you extend UFT One support for a control you always do so in the context of a toolkit. For the purpose of this tutorial, two custom Web controls are grouped to form the custom toolkit named WebExtSample: Book and UsedBooks.

    You created the toolkit support set for this toolkit in the previous lesson. In this lesson you add support for the UsedBooks control in the WebExtSample toolkit support set.

  5. Complete the custom control support planning checklist.

    This section describes the decisions you need to make when planning your support for the UsedBooks control, and then summarizes the information in the support planning checklist.

    1. Choose the test object class to represent the custom control:

      The internal content of the UsedBooks control is implemented as a Web table control because of the type of information it contains. For the purpose of performing tests on the UsedBooks control and checking the information it contains, it is appropriate that UFT One recognize this control as a table. However, to optimally support the UsedBooks control, the test object that represents the control must support a SelectBook test object method that selects a book from the table by selecting the radio button in the correct row in the table, and clicking Select.

      In addition, because the first row in the UsedBooks table contains the column names, it would be helpful to replace (or override) the RowCount test object method supported for WebTable objects to reduce the row count and return the number of used copies available for this book. To support the SelectBook test object method and override the implementation of RowCount, you create a new test object class named WebExtUsedBooks, which extends WebTable. You then teach UFT One to identify this test object class as the one that represents the UsedBooks control.

    2. Define how UFT One identifies which test object class to use to represent the control:

      If the following conditions are met, use a WebExtUsedBooks test object to represent the control:

      • The control's tagName property is div.

      • The tagName property of the control's first child is table.

      • The className property of the control's first child is UsedBooks.

    3. Decide the details for the new test object class:

      • The new test object class is represented by the icon file: <UFT One installation folder>\dat\Extensibility\Web\Toolkits\WebExtSample\Res\WebBookList.ico

      • No Help file is provided.

      • The WebExtUsedBooks test object class needs to support a title identification property (used to uniquely identify the control, and selected by default in the checkpoint properties dialog box, not used for Smart Identification).

      • The name of the test object itself should be the same as its title identification property.

    4. Decide which test object methods to support for the custom control:

      The WebExtUsedBooks test object class needs to support all of the test object operations supported by the WebTable test object class. In addition, it needs to support the SelectBook test object method.

      • All of the operations inherited from the base class, WebTable, can be supported by the table element contained in the UsedBooks control. However, because the table element is a not the root element of the UsedBooks control, UFT One does not recognize this element as the base element. You must implement a JavaScript function that returns the table element as the base element for the UsedBooks control. This instructs UFT One to use the table element to support the operations inherited from the base WebTable test object class.

      • The SelectBook test object method simulates selecting the radio button for the specified book and clicking Select.

      • The WebTable test object method RowCount needs to be overridden, to return the actual number of books in the table instead of the number of rows.

    5. Define which of the control's children UFT One should learn when learning the control:

      For the purpose of this tutorial, when a WebExtUsedBooks test object is learned as part of a Web page, the radio buttons within in should be learned as well.

    6. Decide whether the Object Spy should display WebExtUsedBooks test objects: Yes.

    7. Decide whether to support recording, and what events to record:

      Listen to mouse clicks that occur on the Select link. When a radio button is selected and this link is clicked, record a test step that selects the book whose radio button is selected.

    8. Decide what parts of the support need to be designed in the toolkit configuration file and what parts need JavaScript functions:

      • For the UsedBooks control, test object class identification is performed by a JavaScript function, specified in the toolkit configuration file. To avoid unnecessary calls to the JavaScript function, a condition element is defined in the toolkit configuration file, instructing UFT One to call the JavaScript function only if the control is defined as a div element.

      • The table base element must be returned by a JavaScript function specified in the toolkit configuration file.

      • Test object identification properties can be supported by JavaScript functions using the default naming convention, therefore no changes are required in the toolkit configuration file.

      • The WebTable's RowCount test object method is overridden by a new implementation, provided by a JavaScript function named BookCount. Therefore, the name of the function needs to be specified in the toolkit configuration file.

      • Filtering the children that are learned with the UsedBooks control is done by calling a JavaScript function that needs to be specified in the toolkit configuration file.

      • To support recording, you modify the toolkit configuration file to turn off the default Web Event Configuration and specify the JavaScript function that registers UFT One to listen to the correct event. In addition, you design one JavaScript function that handles event registration, and additional JavaScript functions that instruct UFT One to record the relevant steps when the events occur.

You can see the checklist, completed based on the information above.