Recording New Classes for .NET Controls

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

After you enable extensions for testing a .NET Windows Forms application with the Classic Agent, if you see CustomWin declarations in the Record Window Declarations, then click Record > Class in order to work with the CustomWin controls. The process of recording a class involves querying the objects in your application, retrieving information on properties and methods, and then translating the information into 4Test-style prototypes. Silk Test Classic does this automatically when you click Record > Class.

When you use the Record Class dialog box to record new classes for .NET controls, Silk Test Classic automatically inserts the __typeinfo keyword in front of any method that has parameters that are either:
  • Of type POINT or RECT.
  • Of a type that has been declared explicitly in 4Test and uses the alias mechanism.

We recommend that you create an include file, for example userclass.inc, for your new class definitions, instead of entering them in dotnet.inc. The dotnet.inc include file is shipped with Silk Test Classic and we reserve the right to modify this file in future releases. If you modify dotnet.inc, you may have to integrate your changes into future versions of that file.

To record new classes:

  1. Start the .NET standalone Windows Forms application.
  2. Open the include file that you created for your new class definitions. For information on how to load class definition files, see Several Ways to Load Class Definition Files.
  3. Click Record > Class > Scripted to open the Record Class dialog box.
  4. Position the mouse pointer over the control for which you want to record a class.
  5. When the correct name displays in the Window text box, press Ctrl+Alt.

    Properties and methods for that class are displayed in the Record Class dialog box. Do not edit the tag name in the Tag text box. If you check Show all methods on the Record Class dialog box, you see a commented section called Other methods. Some methods are preceded by two slashes (//) and others are preceded by three slashes plus two asterisks (/// ** ). The methods that are preceded by "/// ** " cannot be called by Silk Test Classic; they are included only for reference purposes.

    The methods in the Other methods section that are preceded by two slashes can potentially be called by Silk Test Classic. These are methods that:
    • Have parameters or return values of a type not declared in 4Test. To call such a method, you must explicitly declare the types using alias. The data types in the argument list are just suggestions. You must consult the documentation for the control in order to determine the native data type name and definition. After you have declared the types, you should compile your frame file and click Record > Class. Now the recorder will recognize your new data types and will record as usable those methods that were previously commented out because the data types had not been defined.
    • Are overloaded methods, in other words methods for which the parameter list may vary. 4Test does not support overloading of methods, since each method must have a unique name. You may choose to un-comment one of the overloaded methods for use within your test scripts.
  6. Click the Derived From list box to see the list of available 4Test classes. Then proceed as follows:
    • If there is a class type available that maps directly to your object, choose it. For example, if your object is a SuperListBox, you would likely choose ListBox. Your object will inherit all the standard 4Test methods and properties defined for a list box.
      Note: Similarly named objects might not behave as expected.
    • If there is not a class type that maps directly to your object, choose Control, which is a generic class.

    See winclass declaration and derived class for more details.

    The Agent provides special handling for certain classes of objects. If your object is one of these types, but does not work correctly while you are testing your application, you will also need to class map the object after completing this procedure. For additional information, see Options for Non-Graphical Custom Controls.

  7. Click Paste to Editor to paste the new class into the include file.
  8. Repeat this process for every type of control in your application that does not display in the list of classes provided.
  9. When you are done recording classes, click Close.