Plan 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 the section on understanding the Web Add-in Extensibility planning checklist in the Micro Focus UFT One  Web Add-in Extensibility Developer Guide, and fill in the 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.

    Close the Object Spy.

  3. Record operations on the Book 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. 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>
  6. 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. Consider how UFT One can identify which test object class to use to represent the control. Keep in mind, however, that Extensibility Accelerator includes a point-and-click mechanism that you can use to automatically create rules for mapping test object classes to controls. Therefore, you do not have to make a final decision regarding these rules at the planning stage.

      A WebExtBook test object can be used to represent the control if the control's tagName property is table and its className property is Book.

    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\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. Decide whether the Object Spy should display WebExtBook test objects: Yes.

    6. 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.

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