Register a function using the Function Definition Generator
Relevant for: GUI tests and components
This topic describes how to create and register a user-defined function using the Function Definition Generator.
Open the function library/test and the Function Definition Generator
-
Make sure that the function library or action in which you want to insert the function definition is the active document. This is because the Function Definition Generator inserts the function in the currently active document after you finish defining it.
-
Select Design > Function Definition Generator.
Specify the details
-
In the Function definition section, give the function a unique name.
-
Select the type for the function: Function or sub (subroutine).
-
Specify the type for the function:
-
Public: The function can be called by any test or component (via the application area) associated with the function library
-
Private: The function can be called only from this function library.
Note: If you are overriding an existing test object class method, select the Public option.
-
Register the function to a test object class - optional
-
Below the function name, select the Register to a test object checkbox.
-
Select the test object from the list of available objects.
-
Enter the name of a new operation that you want to add to the test object class, or select an existing operation to specify the operation that you want to override its standard functionality. The name of the method cannot contain spaces.
-
If necessary, specify that this operation is the default operation for test objects of this type.
Tip: If you choose not to register your function at this time, you can manually register it later by adding a RegisterUserFunc statement. You can also add additional RegisterUserFunc statements, to register the function to additional test object classes.
Add argument
-
In the Arguments box, click the Add button to add the necessary arguments for the function.
-
For each argument, in the Pass mode cell, specify how the value is passed to the function:
-
By value: A value entered into the function
-
By reference: The function references the value.
-
Add documentation details
In the Additional information box, enter the details of the function:
-
Description: The description of the function displayed as a tooltip when you hover over the function name.
-
Documentation: The description of the function displayed in the Documentation column of the Keyword View after you enter the necessary arguments.
Insert the function
Click OK or Insert. OpenText Functional Testing inserts the generated VBScript code in the active document.
Add the content (code)
To finalize the function, add content to the function code, as required, replacing the TODO comment.
The function is now available to your tests, components, or function libraries (depending on where the function was generated and the context in which you are working). If you registered the function to a test object, this function is displayed in the list of available functions for the test object (in the Keyword View and Editor).