Note: VuGen's code regeneration overwrites all manual changes that you made to a recorded script; it only regenerates the recorded functions.
- Click Record > Recording Options. Select Script in the General menu on the left.
- Click OK.
After recording the script, the default C files are replaced by JS files.
Note: Once you have recorded your script the Language option in the Recording Options dialog box is disabled and cannot be changed. You can change the language of a script after it is recorded only by regenerating it.
Caution: If you changed a recorded script, your changes are lost when you regenerate.
- Click or Record > Regenerate Script. A warning appears that any changes to the code are overwritten.
- Click Options. The Regenerate Options dialog box appears.
- In the Script section, select the target language to convert the script to.
- Click OK in the Regenerate Options dialog box. Click OK to approve regenerating the code.
- web: Web/HTTP Protocol API.
- lr: LoadRunner native API.
- vtc: VTC multiple connections API.
- lrvtc: VTC single connections API.
Before you can invoke custom functions, add your custom library into the Extra files section. Your custom library must have a 'js' extension.
To activate auto-completion on your library, right click on the js file name and select Add to Parsing List.
Note: If you regenerate your script in another language, any additional files, such as a user-defined .js file, are removed from the parsing list.
lr.loadLibrary is used to “include” a single file into the script. The code is evaluated and its definitions are added to the global scope of the runtime context. For example:
lr. loadLibrary (‘external.js’);. lr.loadLibrary can be used for browser based libraries.
lr.require loads a CommonJS file or NPM module into a string, then wraps it with a function and evaluates it. Additional required files are loaded recursively along the “require” link.
Example: var lodash = lr.require("..\\node_modules\\lodash");
var sum = lodash.sum([1,2,3,4]);