Supporting Wrapper Controls

A wrapper control is a container control that groups the controls within it and represents them as a single control. An example of wrapper control is the AwtCalc calculator control.

When UFT One learns a wrapper control, it does not learn the controls within it separately as descendants. If you record a test on a wrapper control, events that occur on the controls within it are recorded as operations on the wrapper control.

Note: Only AWT-based controls can be supported on UFT One as wrapper controls. If the custom control is SWT-based, it is always learned with all of its descendants.

For example, the AwtCalc calculator control contains simple buttons for digits and operators. In a recording session on this control, you might want simple Click operations to be interpreted as more meaningful calculator-oriented operations. You can use Java Add-in Extensibility to instruct UFT One to record clicks on digit buttons as Calculator.SetValue steps, and clicks on operator buttons as Calculator.SetOperator steps.

Understanding How UFT One Handles Wrapper Controls

Wrapper controls must register themselves as wrappers for the types of controls that they wrap.

Before UFT One learns a control as a descendant, UFT One checks if any wrappers are registered for this type of control. If there are registered wrappers, UFT One searches for the one to which this particular control belongs. UFT One performs this search by calling the checkWrappedObject method of each registered wrapper. If UFT One finds a relevant wrapper, UFT One does not learn the descendant control. If no relevant wrapper is found, UFT One learns the descendant control.

When a control is learned separately (by clicking on the specific control), UFT One does not check for wrappers.

Similarly, before UFT One records an operation on a control, UFT One checks if any wrappers are registered for this type of control. If there are registered wrappers, UFT One searches for the one to which this particular control belongs. If UFT One finds a relevant wrapper, UFT One passes the record message to the wrapper control before adding a step to the test. If no relevant wrapper is found, the operation is recorded as is.

When the wrapper receives a record message (triggered by an operation performed on one of its wrapped objects), it can do one of the following:

  • Discard the message to prevent the recording of the operation.

  • Modify the message to record a different operation.

  • Leave the message as is to record the operation without intervention.

The following section describes how this mechanism is implemented, using the AwtCalc wrapper control as an example. After support for the AwtCalc control is implemented, a test recorded on the control could look like this:

Implementing Support for Wrapper Controls

If you want to support a wrapper control, you must implement the com.mercury.ftjadin.infra.abstr.RecordWrapper interface in MicAPI. This interface includes the following methods:

See also: