Using XML Files to Extend Support for a Custom Control

You can implement custom control support without programming a .NET DLL. To do this, you enter the appropriate Test Record and Test Run instructions for the custom control in a control definition file.

Overview

Create a separate control definition file for each control you want to customize. In the control definition file, provide Test Record and Test Run instructions for the custom control.

You can instruct UFT One to load the custom control implementation instructions by specifying each control definition file in the .NET Add-in Extensibility configuration file, SwfConfig.xml.

Note: When extending support using an XML file, UFT One generates an ad hoc .NET DLL for you based on the XML file. This ad hoc .NET DLL becomes the custom server for the control.

When using this technique, you do not have the support of the .NET development environment—the object browser and the debugger— or the ability to create table checkpoints or output values. However, by enabling the implementation of custom control support without the .NET development environment, this technique enables relatively rapid implementation, even in the field.

This feature is most practical either with relatively simple, well documented controls, or with controls that map well to an existing object but for which you need to replace the Test Record definitions, or replace or add a small number of test object Test Run methods.

Back to top

Understanding Control Definition Files

The control definition file can contain a Record element in which you define the customized recording for the control and a Replay element in which you define the customized test object methods.

  • The Record element specifies the control events for which you want UFT One to add steps to the test (or component) during a recording session. The steps are calls to test object methods of the custom control's test object.

  • The Replay element specifies the operations that UFT One should perform on the control for each test object method during a run session.

You do not always need to enter both a Record and a Replay element:

  • If the Test Record implementation for the custom test object should be different than the one defined for the existing test object, create a Record element in the control definition file for the custom control.

  • Similarly, if the Test Run implementation for the custom test object should be different than the one defined for the existing test object, create a Replay element in the control definition file for the custom control.

If you create a Record element, the definitions replace the Test Record implementation of the existing test object entirely. If you create a Replay element, it inherits the Test Run implementation of the existing object and extends it. For more information on test object mapping options, see Map the Custom Controls to the Relevant Test Objects .

For information on the elements in a control definition XML file, see the .NET Add-in Extensibility Control Definition Schema Help).

Back to top

An Example of a Control Definition File

The following example shows the handling of an object whose value changes at each MouseUp event. The value is in the Value property of the object. The MouseUp event handler has Button, Clicks, Delta, X, and Y event arguments.

The Record element describes the conversion of the MouseUp event to a SetValue command. The Replay element defines the SetValue command as setting the value of the object to the recorded Value and displaying the position of the mouse pointer for debugging purposes:

<?xml version="1.0" encoding="UTF-8"?>
<Customization>
    <Record>
        <Events>
            <Event name="MouseUp" enabled="true">
                <RecordedCommand name="SetValue">
                    <Parameter>
                        Sender.Value
                    </Parameter>
                    <Parameter lang="C#">
                        String xy;
                        xy = EventArgs.X + ";" + EventArgs.Y;
                        Parameter = xy;
                    </Parameter>
                </RecordedCommand>
            </Event>
        </Events>
    </Record>
    <Replay>
        <Methods>
            <Method name="SetValue">
                <Parameters>
                    <Parameter type="int" name="Value"/>
                    <Parameter type="String" name="MousePosition"/>
                </Parameters>
                <MethodBody>
                    RtObject.Value = Value;
                    System.Windows.Forms.MessageBox.Show(MousePosition, "Mouse Position at Record Time");
                </MethodBody>
            </Method>
        </Methods>
    </Replay>
</Customization>

Back to top