Defining New Classes with the Classic Agent

This functionality is supported only if you are using the Classic Agent.

Consider the declarations for the Open and the Save As dialog boxes of the Text Editor application, which each contain exactly the same child windows:

window DialogBox Open

   tag "Open"
   parent TextEditor
   StaticText FileNameText
      tag "File Name:"
   TextField FileName1
      tag "File Name:"
   ListBox FileName2
      tag "File Name:"
   StaticText DirectoriesText
      tag "Directories:"
   StaticText PathText
      tag "#3"
   ListBox Path
      tag "#2"
   StaticText ListFilesOfTypeText
      tag "List Files of Type:"
   PopupList ListFilesOfType
      tag "List Files of Type:"
   StaticText DrivesText
      tag "Drives:"
   PopupList Drives
      tag "Drives:"
   PushButton OK
      tag "OK"
   PushButton Cancel
      tag "Cancel"
   PushButton Network
      tag "Network"

window DialogBox SaveAs

   tag "Save As"
   parent TextEditor
   StaticText FileNameText
      tag "File Name:"
   TextField FileName1
      tag "File Name:"
   ListBox FileName2
      tag "File Name:"
   StaticText DirectoriesText
      tag "Directories:"
   StaticText PathText
      tag "#3"
   ListBox Path
      tag "#2"
   StaticText ListFilesOfTypeText
      tag "List Files of Type:"
   PopupList ListFilesOfType
      tag "List Files of Type:"
   StaticText DrivesText
      tag "Drives:"
   PopupList Drives
      tag "Drives:"
   PushButton OK
      tag "OK"
   PushButton Cancel
      tag "Cancel"
   PushButton Network
      tag "Network"

It is not uncommon for an application to have multiple dialogs whose only difference is the caption: The child windows are all identical or nearly identical. Rather than recording declarations that repeat the same child objects, it is cleaner to create a new class that groups the common child objects.

For example, here is the class declaration for a new class called FileDialog, which is derived from the DialogBox class and declares each of the children that will be inherited by the SaveAs and Open dialog boxes:

winclass FileDialog : DialogBox
   parent TextEditor
   StaticText FileNameText
      tag "File Name:"
   TextField FileName1
      tag "File Name:"
   ListBox FileName2
      tag "File Name:"
   StaticText DirectoriesText
      tag "Directories:"
   StaticText PathText
      tag "#3"
   ListBox Path
      tag "#2"
   StaticText ListFilesOfTypeText
      tag "List Files of Type:"
   PopupList ListFilesOfType
      tag "List Files of Type:"
   StaticText DrivesText
      tag "Drives:"
   PopupList Drives
      tag "Drives:"
   PushButton OK
      tag "OK"
   PushButton Cancel
      tag "Cancel"
   PushButton Network
      tag "Network"

To make use of this new class, you must do the following:

  1. Rewrite the declarations for the Open and Save As dialog boxes, changing the class to FileDialog.
  2. Remove the declarations for the child objects inherited from the new class.

Here are the rewritten declarations for the Open and Save As dialog boxes:

window FileDialog SaveAs
   tag "Save As"
window FileDialog Open
   tag "Open"

For more information on the syntax used in declaring new classes, see the winclass declaration.

The default behavior of Silk Test Classic is to tag all instances of the parent class as the new class. So, if you record a window declaration against a standard object from which you have defined a new class, Silk Test Classic records that standard object’s class as the new class. To have all instances declared by default as the original class, add the following statement to the declaration of your new class: setting DontInheritClassTag = TRUE. For example, let’s say you define a new class called FileDialog and derive it from the DialogBox class. Then you record a window declaration against a dialog box. Silk Test Classic records the dialog box to be of the new FileDialog class, instead of the DialogBox class. To have Silk Test Classic declare the class of the dialog box as DialogBox, in the FileDialog definition, set DontInheritClassTag to TRUE. For example:

winclass FileDialog : DialogBox
  setting DontInheritClassTag = TRUE