Stage 7: Implementing a Filter to Prevent Learning Child Objects

When you instruct UFT One to learn a Web page, the Define Object Filter dialog box opens, enabling you to determine which of the Web page's descendants should be learned with it. When you select All object types, instructing UFT One to learn the WebExtBook control with its parent Web page, all of the controls that the WebExtBook control contains are also learned as children of that Web page (and siblings of the WebExtBook control).

In the case of the Book control, there is no need to create test objects for all of its children, as described in Planning Support for the Web Add-in Extensibility Book Sample Toolkit.

To prevent UFT One from learning all of the descendants of a control supported by Web Add-in Extensibility, you can define a Learn Filter. Complex filters can be implemented using a JavaScript function, in which case you specify the location and name of the function in the toolkit configuration file. Simple filters can be implemented directly in the toolkit configuration file, without using JavaScript functions.

To prevent learning the controls contained in the Book control, a simple filter is sufficient. Before you implement this filter, learn the Web page that contains the Book control with all of its descendants to see that all of the Book's children are learned as well. To do this, you can follow the procedure described in Deploying and Testing the Toolkit Support Set (for Stage 7).

To prevent learning the controls contained in the Book control:

In the WebExtSample.xml file, within the Control element defined for the WebExtBook test object class, add the following Filter element:

<Filter>
    <Learn learn_control="Yes" learn_children="No"/>
</Filter>

This instructs UFT One to learn WebExtBook test objects when learning their parent Web pages, but not to learn the child controls they contain.

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

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