Recording a Method for a GUI Object

If you need to perform an action on an object, which is not supported by the class of the object, you can record or manually script a new method that performs the action. Add the new method to the class or to the window declaration of the object to use the method in the same way as the built-in methods of the class.

You can use the Record Method dialog box to record a method for a class or window declaration.

Note: Before you can record a method, you must have recorded window declarations.
  1. Open an include file or script file.
  2. Move the mouse cursor into the declaration of the GUI object to which you want to add a method.
  3. Click Record > Method.
    Note: This is only available when an include file or script file is the active window and the mouse cursor is within a class or object declaration because methods are necessarily part of a class or object definition.
    The Record Method dialog box appears.
  4. Type a name for the method into the Method name field. You can also select one of the predefined methods:
    • BaseState
    • Close
    • Invoke
    • Dismiss
  5. Click Start Recording. Silk Test Classic is minimized and displays the application under test.
    • If you are using the Open Agent, the Recording window appears.
    • If you are using the Classic Agent, the Record Status on Classic Agent dialog box appears.
  6. Perform and record the actions that you require.
  7. Stop recording.
    • If you are using the Open Agent, click Stop Recording.
    • If you are using the Classic Agent, click Done.
    The Method code field in the Record Method dialog box displays the actions that you have recorded translated into 4Test statements.
  8. On the Record Method dialog box, click OK to paste the code into the file in the editor.
  9. Edit the 4Test statements that were recorded, if necessary.
Note: To add a method to a class which is using the Open Agent, you can also copy the method into the script from a recorded test case.