Recording Classes for Custom Java Controls Using the Recorder

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

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 to Test Java.

To record new classes for custom controls using the recorder:
  1. Start your Java application or applet.
  2. Create a new include (.inc) file, open an existing include file, or open the test frame file for storing your new class definitions.
  3. Click Record > Class > Scripted to open the Record Class dialog box.
  4. To include native methods with return or parameter types that do not match valid 4Test methods, check the Show all methods check box in the lower left corner of the dialog box. You cannot call these methods directly from your 4Test scripts but you can use the InvokeMethods or the InvokeJava method to call them. When you capture the class, Silk Test Classic displays these methods prefaced by comments in the Record Class dialog box. When you click Paste to Editor, Silk Test Classic adds the InvokeMethods method and these methods, prefaced by comments, to your test script.
  5. Position the mouse pointer over the control for which you want to record a class.
  6. When the correct name displays in the Window text box, press Ctrl+Alt. Methods and properties for that class are displayed in the Record Class dialog box. If you have checked Show All Methods, Silk Test Classic displays these non-4Test methods as comments, that is, prefaced by forward slashes (//).
  7. Click the Derived From list box to see the list of available 4Test classes. If there is a class type in the list that maps directly to your object, choose it. If not, choose AnyWin, which is a generic class. For example, if your object is JavaAwtTextField, choose TextField. If your object is Spinner, choose Anywin. For additional information, see winclass Declaration and derived class.
  8. Click Paste to Editor to paste the new class into the include file.
  9. Uncheck the Show all methods check box in the Record Class dialog box, if you chose it for this record action.
  10. Repeat this procedure for each custom control that does not display in the predefined list of Java classes provided. When you are finished recording classes, click Close.
  11. 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.

To include native methods with return or parameter types that do not match valid 4Test methods, check the Show All Methods check box on the Record Class dialog box. Silk Test Classic displays these methods as comments in Methods list.

When you finish recording the class, uncheck the Show all methods check box to turn off the recording of all methods. Turning off Show all methods when you don’t need it helps to keep performance optimal.

Although you cannot call these methods directly from your 4Test script, you can use InvokeMethods or InvokeJavaCode to call them from your script.

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.