Creating the UFT One Custom Static-Text Support Class

In the lesson Learning to Support a Simple Control, you created the ImageControlsSupport UFT One Java Add-in Extensibility project. In that project, you created the custom support class for the ImageButton control.

In this section you create another custom support class in the same project to support the ImageLabel control.

Overview

In most cases, static-text controls do not have identification properties or test object methods that need to be identified in UFT One tests. In addition, there is usually no need to record any operations on a static-text control. Therefore, the UFT One Java Add-in Extensibility Eclipse plug-in provides a special wizard for creating support classes for static-text controls.

In this wizard, all you have to do is select the ImageLabel class to be supported as a static-text control. The wizard creates the new support class with all the required methods. After the wizard creates the new support class, you modify the methods that the wizard creates to complete the support.

Back to top

Create a Custom Static-Text Support Class

  1. Open the New UFT One Custom Static-Text Support Class wizard.

    1. In the Eclipse Package Explorer tab, select the UFT One Java Add-in Extensibility project, ImageControlsSupport. Select File > New > Other. The New dialog box opens.

    2. Expand the UFT One folder and select UFT One Custom Static-Text Support Class.

    3. Click Next. The Custom Class Selection screen opens.

  2. Select the custom class to support, and set the options for the support class.

    1. Expand the com.demo package and select the ImageLabel class.

      Since you are creating support for a class in the ImageControls custom toolkit, the Custom toolkit tree pane looks similar to the one in the lesson Learning to Support a Simple Control, as shown in Creating a New UFT One Custom Support Class. The Custom toolkit tree represents the list of classes that you can select to support. The ImageButton class does not appear in this list because you already created support for it.

      In the Custom class inheritance hierarchy pane, you can see the hierarchy of the ImageLabel class you have selected. It extends the ImageControl class, which is part of the same toolkit, and is therefore shown in black.

      The ImageControl custom class is not supported, but the Canvas class does have a matching support class, provided in the com.mercury.ftjadin.support.awt.cs package. Therefore the Base support class for the ImageLabel support class you are creating is CanvasCS. This is the class that your new support class extends.

      The Controls of this class represent top-level objects option is disabled because the ImageLabel class is not a container class.

      The name for the ImageLabel support class is, by default, ImageLabelCS. It is recommended to keep the default name.

    2. Click Finish. The Custom Static-Text Support Class Summary screen opens.

  3. View the custom static-text control support class summary.

    Review the planned content of the custom static-text support class, and click OK.

    The following changes are made in the ImageControlsSupport project:

    • The ImageControls.xml file is modified to map the ImageLabel custom class to its support class—ImageLabelCS.

    • A new UFT One custom support class, ImageLabelCS, is created in the ImageLabelCS.java file in the com.mercury.ftjadin.qtsupport.imagecontrols.cs package. The file is opened and displayed in a tab in the right pane.

      For a detailed explanation of the content of the ImageLabelCS class, see Understanding the New Custom Static-Text Support Class.

  4. The asterisk (*) next to the ImageLabelCS file name (in the ImageLabelCS tab) indicates that it has not been saved. The changes made by the wizard are codependent, and must be saved to prevent discrepancies. Select File > Save, or click the Save button.

Back to top

Understanding the New Custom Static-Text Support Class

Examine the contents of the new ImageLabelCS.java file. The ImageLabelCS custom static-text support class extends CanvasCS.

In the new support class, the wizard created stubs for the following methods:

  • class_attr. Returns the string static_text.

    This informs UFT One that the ImageLabel control is a JavaStaticText object. This means that the UFT One mechanism that searches for attached text can use the ImageLabel's label property as attached text for adjacent controls.

  • label_attr. Returns the label property of the superclass (in this case CanvasCS).

    This method defines ImageLabel's label identification property. The text in this identification property is used for adjacent controls' attached text. The wizard includes a comment in this method stub, reminding you to implement it to return the appropriate text.

  • tag_attr. This method supports the tag property, which represents the name of the static-text test object.

    In the lesson Learning to Support a Simple Control, in the section Changing the Name of the Test Object, you learned how the tag property is implemented. The tag_attr method in the support class that the wizard creates returns super.tag_attr(obj) with the added suffix (st). This means that the name for the static-text test object is derived by using the same logic as for regular test objects (label, attached text or unqualified class name), and adding (st) at the end.

  • value_attr. Returns the label property.

    The value property represents a control's test object state. For static-text controls, the label property adequately represents this state.

For more information on these special identification properties, see Common Identification Property Support Methods.

Back to top

Next steps: