Example: Customizing Recording of an Event's Meaningful Behaviors

A control's meaningful behavior is the behavior that you want to test. For example, when you click a button in a radio button group in your application, you are interested in the value of the selection, not in the Click event and the coordinates of the click. The meaningful behavior of the radio button group is the change in the selection.

If you record a test or business component on a custom control without extending support for the control, you record the low-level behaviors of the control.

Example: The TrackBar control in the sample .NET application shown below is a control that does not have a corresponding UFT test object.

If you record on the TrackBar without implementing support for the control, the Keyword View looks like this:

In the Editor, the recorded test looks like this:

SwfWindow("Sample Application").SwfObject("trackBar1").Drag 50,10
SwfWindow("Sample Application").SwfObject("trackBar1").Drop 32,11
SwfWindow("Sample Application").SwfObject("trackBar1").Drag 34,11
SwfWindow("Sample Application").SwfObject("trackBar1").Drop 51,12
SwfWindow("Sample Application").SwfObject("trackBar1").Drag 50,4
SwfWindow("Sample Application").SwfObject("trackBar1").Drop 23,7
SwfWindow("Sample Application").SwfObject("trackBar1").Click 83,10
SwfWindow("Sample Application").SwfObject("trackBar1").Click 91,11
SwfWindow("Sample Application").SwfButton("Close").Click

Note that the Drag, Drop, and Click methods—the low-level actions of the TrackBar control—are recorded at specific coordinates in the control display. These steps are difficult to understand and modify.

If you use .NET Add-in Extensibility to support the TrackBar control, the result is more meaningful.

Example: Below is the Keyword View of a test recorded on the TrackBar with a Custom Server that implements a customized SetValue method.

In the Editor, the recorded test looks like this:

SwfWindow("Sample Application").SwfObject("trackBar1").SetValue 5
SwfWindow("Sample Application").SwfObject("trackBar1").SetValue 0
SwfWindow("Sample Application").SwfObject("trackBar1").SetValue 10
SwfWindow("Sample Application").SwfObject("trackBar1").SetValue 6
SwfWindow("Sample Application").Close

UFT is now recording a SetValue operation reflecting the new slider position, instead of the low-level Drag, Drop, and Click operations recorded without the customized test object. You can understand and modify this test more easily.