Work with JavaScript
This topic contains tips for coding in JavaScript in your TruClient scripts.
JavaScript support
The JavaScript editor uses standard JavaScript functionality, including automatic word completion, and provides access to the TruClient functions. Use the right-click menu to access JavaScript actions.
JavaScript is supported in three places in TruClient:
-
Arguments. The arguments listed in the Arguments section of each step are all JavaScript-based, and can accept JavaScript expressions that are evaluated during script replay.
-
Descriptor ID method. The Value field in Descriptor ID method can accept JavaScript expressions that are evaluated during script replay.
-
JavaScript ID method. The JavaScript ID method can accept JavaScript expressions that are evaluated during script replay.
Custom code snippets
In addition to the built-in JavaScript code snippets, you can create your own custom code snippets for reusable blocks of code. When editing JavaScript code, for example, in an Evaluate JavaScript step, you can use the snippets to speed up the coding process.
To use snippets in the JavaScript code:
-
Open the General settings > Code snippets tab.
-
Click Add a new code snippet . A new code snippet template is opened, using a default label.
-
Edit the snippet Label and define Documentation to describe its purpose.
The label is used to access the snippet in the editor.
-
Click Save in the General settings dialog box.
-
When creating or editing an argument for a step in the JavaScript editor, start typing the label for the snippet. Select the snippet from the auto-suggest list, to add the snippet content to the code.
See also: