Recording Classes for Custom Java Controls from a Script

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

Silk Test Classic provides two functions that allow you to capture the class information of custom Java controls from a script:

  • CaptureAllClasses
  • CaptureObjectClass

The following procedure explains how to use these functions to record new classes for custom Java controls. Before beginning this procedure, make sure you have taken the necessary prerequisite steps to set up your environment as described in Configuring Silk Test Classic Java Support and Overview of Testing Java Applications and Applets.

To record new classes for custom controls from a script:

  1. Start your Java application or applet.
  2. Create a new include (.inc) file, open an existing include file, or open an existing test frame file for storing your new class definitions.
  3. Open a new script (.t) file.
  4. Load the include file captureclass.inc, located in the directory where you installed Silk Test Classic.
    Note: We recommend loading this include file only in the scripts that call CaptureObjectClass or CaptureAllClasses.
  5. Open the windows that contain the custom controls and their parent windows.
  6. Record declarations for the windows containing your custom controls and paste the declarations into your script file.
  7. In your script file, write a main routine that calls one or both of the capture functions, according to the following guidelines:
    If you want to capture … Call …
    The class for one custom control CaptureObjectClass.
    The class for a custom control and all of its children CaptureAllClasses.
  8. Save and run your script file. The results file opens on your desktop and contains the new class definitions.
  9. Copy the class definitions from your results file and paste them into the include file you have designated in step 2.
  10. Load the include file that contains the new class definitions.
  • If you find that Silk Test Classic does not recognize some of your custom Java controls, you may need to take additional steps to record classes for these "ignored" objects.
  • If you add or delete native methods, or modify the parameters of native methods for a custom Java class, you need to either re-record the class or edit your class include file to reflect the changes.
  • If your test script fails with the error Function x is not defined for window y, you might need to modify your window tag from CustomWin to the name of your new window class. For the correct sequence of steps to perform before you begin writing test scripts, see Testing Java Applications and Applets.