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