Knowledge Base Article

> Knowledge Base > Rapise

by  Adam S Wednesday, October 31, 2012

Sometimes you want a test script to be able to call another sub-test as part of its operation. You can do this using the Global.DoInvokeTest('path to test', [parameters]); function. This articles provides a more detailed example for doing this.

The high-level information can be found on our website at:

For this example we shall have a Parent test called (ParentTest.sstest) call a child test (called ChildTest.sstest) and pass some parameters and also check the pass/fail status of the called test.

The child test consists of a simple recording against the sample Library Information System website ( and has the following script:

Contents of ChildTest.sstest.js

function Test(params)
 //Set the defaults and override if we have parameters passed-in
 g_username = 'librarian';
 g_password = 'librarian';
 if (params.username)
  g_username = params.username;
 if (params.password)
  g_password = params.password;

 //Log out the variables
 Tester.Message('g_username: ' + g_username)
 Tester.Message('g_password: ' + g_password)
 //Click on Log In
 //Set Text librarian in Username:
 //Set Text librarian in Password:
 //Click on ctl00$MainContent$LoginUser$LoginButton
 //Click on Log Out
 //Close the browser
 //Set the test return value for the parent test
 g_testPassed = testResult;

g_load_libraries=["%g_browserLibrary:Internet Explorer HTML%", "DOM GWT", "DOM YUI"];

Notice how the main Test() function has an additional variable called "params", that will contain a Javascript object collection of variables and values. We will pass through two variables, "username" and "password".

Also notice how we have sent the return value automatically by using the g_testPassed = testResult; command. g_testPassed is a special built-in Rapise variable used to send back the results to the parent test and testResult is an internal variable containing the result of the current test.

Now, the code for the calling parent test is as follows:

Contents of ParentTest.sstest.js

//Calls the child test with a different login/password
function Test()
 var params = { username: 'borrower', password: 'borrower' };
 var result = Global.DoInvokeTest('..\\ChildTest\\ChildTest.sstest', params);
 Tester.Assert('Result from sub-test', result, 'Result was ' + result)

g_load_libraries=["%g_browserLibrary:Internet Explorer HTML%", "DOM GWT", "DOM YUI"];

Notice how we pass the object collection of parameter names and values to the child test and how we get the pass/fail result from the Global.DoInvokeTest(...) function.

Attached to this article is the full source code as a zipfile.


Selected files will be attached to any email sent on saving ticket.

file selected files selected  () Delete Selected

  • Created:
  • by:

Select files to upload

Or drag and drop files here

Uploading …
Upload More?
There was an error.
Try again?

Save to upload the selected file(s)

Article Info
  • Last Updated: 10/31/2012
  • Article ID: KB25
  • Views: 1627