A TruClient function is a group of steps, such as a login, that you define as a function. Functions are stored in libraries that can be reused multiple times in a script. Each library can contain multiple functions.
Each library can be either local or global. A local library can be accessed by the script that created it. A global library can be accessed by all TruClient scripts. Additionally, a global library can be saved on the network and shared between many users.
Right click on a highlighted step in the script, and then select Group Into > New Function.
What do you want to do?
- Select the Functions Libraries tab at the bottom of the TruClient sidebar.
- Select an existing library from the drop-down or click the button from the Function toolbar to create a new library.
Click the button to create a new function. This will insert a new unspecified function.
- Click the button to expand the function.
- Define the step including function name and end event.
- Define the function arguments using the Argument Editor. Argument names should be meaningful so that when you are using the function it is clear what value you need to specify.
- Define the transaction using the Transaction Editor. For details, see Insert transactions into a TruClient script.
- Highlight the steps in the script to include in the function. To select multiple steps, press CTRL.
- Right-click on a highlighted step and select Group Into > Function which opens the Create a New Function dialog box.
To assign steps that contain arguments, expand the argument section, and insert the function
- Select Function Libraries from the drop-down from the TruClient Sidebar.
- Select an existing library from the drop-down in the TruClient Sidebar.
Click the button to export the library to a location on your file directory as an xml file.
Using the copy paste operation in global libraries
Pasting steps that contain test objects from a local script or a local library to a global library creates separate test object that refer to the same UI element. If you change or update one of the test objects in the global library or in the script, you will need to manually update the other test object that refers to the same UI element.
Global library “GlobLib” contains step A with a test object “Foo” that relates to the application.
Script also contains step B with a test object “Foo” that relates to the application.
If you copy step B and paste it to “GlobLib there are two different test objects in “GlobLib” that related to “Foo”. Therefore, if you change or update one of them you should consider changing the other one manually.
Global library “GlobLib” contains Step A with a test object “Foo” that relates to the application.
Script has steps B and C with a test objects "Foo" that relates to the application. If you copy steps B and C to “GlobLib” there are two different test objects in “GlobLib” that relate to “Foo”.
- Click the TruClient Toolbox tab.
- Select the Functions tab.
- Drag and drop Call Function to the correct location in your script.
- Click the Call Function link to expand the function.
- Specify the library and the function in the step section.
- Specify the arguments' values in the augments section. For details, see Create a function within a script . (Optional)
- Specify transactions in the transaction section. (Optional) For details, see Insert transactions into a TruClient script.
This dialog box enables you create a new function and assign the function to a library.
|Function Name||Enables you to specify a function name.|
|Add to library||
|Replace steps with function call||If selected, TruClient will automatically insert a call function in place of steps.|
- When working with a global library, you can save changes to the library by clicking the button.
- If you save the library to a network location, other users can click the button to import the library.
- Click the button to disconnect the library from global mode. Any changes that you make in local mode are saved within the script.