Functions
Functions allow executing dynamic content in a Scenario. Wherever a variable can be used, a function can be used too.
The standard syntax for functions is "${__myFunction(arg1, arg2)}" where arguments can be variables or functions. For example: "${__func1(${__func2(${myVar})})}".
For more information, see Use variables.
Note: Functions can only be used in NeoLoad 7.1 or above.
JavaScript Libraries
NeoLoad 7.1 is provided with a default library of functions accessible with a click in Edit > JS Libraries.
Each of these functions can be used in a NeoLoad project.
Note: JavaScript functions are ECMAScript6 compatible.
Functions description
The table below identifies all the functions provided by default when creating a new project in NeoLoad. For more details, in NeoLoad, go to Edit > JS Librairies.
Also, any custom function from any custom library can be used if declared in the NeoLoad JavaScript library. For more information, see JavaScript.
Note: To be detected by NeoLoad, functions must be preceded by "__".
| Function name | Description |
|---|---|
| __randomNumber(x, y) | Returns a random number that lies between the given min and max values |
| __urlEncode(url) | Encodes an URL. |
| __urlDecode(url) | Decodes an URL. |
| __escapeHTML(s) | Escapes the characters in a String using HTML entities. |
| __unescapeHTML(s) | Unescapes a string containing HTML entity escapes to a string containing the actual Unicode characters corresponding to the escapes. |
| __randomString(length, chars) | Returns a random String of length using characters in chars to use. |
| __char() | Returns the result of evaluating a list of numbers as Unicode characters. |
| __changeCase(s, mode) | Returns a string value which case has been changed following a specific mode. |
| __intSum() | Returns the sum of two or more integer values. |
| __longSum() | Returns the sum of two or more long values. |
| __getVirtualUserID() | Returns the ID of the VU that is being executed. |
| __getUserPathName() | Returns the name of the Virtual User Path name that is being executed. |
| __getIPAddress() | Returns the local IP address. |
| __getHostName() | Returns the local hostname. |
| __UUID() | Returns a pseudo random type 4 Universally Unique IDentifier (UUID). |
| __digest(algorithm, strToEncode, salt, upperCase) | Returns an encrypted value in the specific hash algorithm with the optional salt and upper case option. |
Migration procedure
Below is the procedure to apply when working with NeoLoad projects prior to 7.1 version:
-
In NeoLoad, create a new project. The default JavaScript library is created in the "Scripts" folder of the new project.
-
Copy the library from the new project to paste it in the "scripts" folder of your existing project.
-
Declare the library as described in JavaScript libraries.