Planning Support for the Web Add-in Extensibility Book Sample Toolkit

In this section, you analyze how UFT One currently recognizes the Book 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 how UFT One recognizes the Book control 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 Book control.

    Open UFT One and load the Web Add-in.

    Close any open instances of the Book control and open it by opening the %ALLUSERSPROFILE%\Documents\ExtAccTool\Samples\WebExtSample\Application\Book.htm file.

  2. Use the Object Spy to view the Book properties and 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 Properties tab and select Identification Properties.

    In the Object Spy dialog box, click the pointing hand , then click the Book control.

    The Book control is implemented as 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 book. The icon used for the test object is the standard WebTable class icon.

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

    Close the Object Spy.

  3. Record operations on the Book control.

    In UFT One, select Record > Record and Run 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. Click on different links in the Book control (you must return to the previous page after each click, to return to the Book control): the book title, the image in the control, an author name, and the Used link.

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

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

    Only simple Click steps are recorded, each attributed to a different object defined within the book control. Click operations are recorded independently on Web Link test objects with different names, or on the Book image test object. These steps are not helpfully meaningful in the context of this control.

  4. Determine the custom toolkit to which the Book 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 UsedBooksTable.

    In this lesson you create support for the WebExtSample toolkit, initially supporting only the Book control.

  5. Complete the custom class support planning checklist.

    The Book control is implemented as a Web table, as follows:

    <table class="Book">
            <td class="BookImageCell" rowspan="4">
                <a href=".\QtpHistory.htm"> 
                    <img class="BookImage" alt="Book" src=".\Res\Book.jpg"/>
            <td class="BookCell">
                <a class="BookTitle" href=".\QtpHistory.htm" > The History of QuickTest Professional </a>
            <td class="BookCell">
                 By: <a href=".\JaneDoe.htm">Jane Doe</a>, <a href=".\JohnDoe.htm">John Doe</a>
            <td class="BookCell">
            <td class="BookCell">
                 New: <strong>59.99$</strong> &nbsp; <a href=".\UsedBooks.htm">Used:</a> from <strong>29.99$</strong>

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

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

      The Book control is implemented as a Web table control to assist in its appearance. For the purpose of performing tests on this control, there is no need to for UFT One to recognize the Book control as a table. On the other hand, the basic support that UFT One provides a generic Web element, using the WebElement object, is not specific enough for the Book control. Therefore, you create a new test object class named WebExtBook, which extends WebElement, and teach UFT One to identify this test object class as the one that represents the Book control.

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

      If the control's tagName property is table and its className property is Book, use a WebExtBook test object to represent the control.

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

      • The new test object class is represented by the icon file: <UFT_One_installdir>\Dat\Extensibility\Web\Toolkits\WebExtSample\Res\WebBook.ico

      • No Help file is provided.

      • The new identification properties to support are: title, authors, price, and min_used_price. They should all be displayed in the UFT One Checkpoint Properties and Output Value Properties dialog boxes, and be selected by default in checkpoints. None are used for Smart Identification.

        The identification properties that uniquely define the object are the book's title and the names of its authors.

      • 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 WebExtBook test object class provides the following test object methods:

      • Select. Simulates clicking the book's title or image. This is the default test object method.

      • GoToAuthorPage. Simulates clicking the specified author name (the available author names should be retrieved from the specific control during run-time).

      • GoToUsedBooksPage. Simulates clicking the Used link.

    5. Determine whether you need to support a dynamic list of values for any method arguments:

      Yes, a dynamic list of values is required for the AuthorName argument in the GoToAuthorPage method. (This requires modifying the toolkit configuration file to specify the JavaScript function that provides the values, and designing the relevant JavaScript function).

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

      For testing purposes, UFT One should relate to all operations as though they are carried out on the Book control itself, even if they are technically performed on controls within it. Therefore, none of the control's children need to be learned and represented by test objects.

    7. Decide whether the Object Spy should display WebExtBook test objects: Yes.

    8. Define whether to support recording, and what events to record:

      Listen to mouse clicks that occur on the following elements in the control: title, image, authors, and Used. When a click occurs on one of these elements, record the relevant step in the test.

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

      • For the simple Book control, test object class identification is based simply on html property values and can therefore be supported using the toolkit configuration file without JavaScript functions.

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

      • Instructing UFT One not to learn the control's children can be designed in the toolkit configuration file and does not require JavaScript functions.

      • 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, 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.