How to store common functions in a separate .js file

Suppose you have common functions and variables that needs to be re-used across different tests.

Here we explain how to include them in your test. Suppose that we have a file CommonUtils.js with a function GetHostInfo(). The function puts information about OS and current user into the report.

Prepare folder structure

We assume that common files are stored in folder:


Include common JS in test

  1. Switch to 'Files' tab.

Files Tab

  1. Right-click on the 'Test' node and choose 'Add File(s)...':

Add File

  1. Now choose a common file. It becomes a part of the test:

File in Test

  1. Now Open "Functions" file in the code editor:

Functions Toolbar

  1. Drag common file from the tree:

Drag Start

To the empty line in the code editor:

Drag End

  1. Now you may use a function from CommonUtil.js from RVL: Common function RVL

or from JavaScript:

function Test()
    // Do the rest

About common file

Common file may contain functions and variables. If functions refer to Objects or contain object actions then different approach should be used (see Include subtests).

Please, note that common JS file should not contain overrides for base prototype (Object.prototype and Array.prototype).