Understanding the Script

Top  Previous  Next


When you create a new test in SmarteStudio, four files are created:

<TestName>.sstest – the test meta-data
<TestName>.js – the test script file
<TestName>.objects.js – the file that contains recorded objects.
<TestName>.user.js – the file that contains user defined functions.

where <TestName> is the name of your Test.


You can have as many javascript files in your test directory as you like, but <TestName>.js is the test script (unless you specify otherwise in the Settings Dialog).  When you record, your interactions are written to <TestName>.js and objects are written to <TestName>.objects.js; when you Playback the test, <TestName>.js is the script that will run.  All SmarteStudio test scripts must have the same basic structure.



If you are going to modify the script, or create a test script from scratch, you will need to know the test script structure:


Basic Script

The Recording tool creates a SmarteStudio Script with three sections:


1. <TestName>.js: A Test() function

//########## Script Steps ##############

function Test()


   //script logic



2. <TestName>.js: A list of required libraries: g_load_libraries

g_load_libraries=["Generic"]; // This script will load the Generic library


3. <TestName>.objects.js A list of learned objects in saved_script_objects.

var saved_script_objects={
   //list of objects used in this script …


All Scripts must have the above three sections.


Full script

The following functions are also recognized by SmarteStudio and may be present in the test script. Put these functions either in <TestName>.js or <TestName>.user.js.


TestInit() : This function is called once before script playback. It should be used to initialize script-wide data (counters, open datasets, etc).


TestFinish() : This function is called once after test execution. It should be used to release resources (data sets, spreadsheets).  TestFinish() is a good place to post-process Reports.   It may also be used as an integration point with external test management or bug tracking systems.


TestPrepare() : For advanced users; TestPrepare() is called before recording and before playback. It may be used to properly initialize libraries.


See Also

To specify a different test script, see the Settings Dialog.  The test script is specified by Settings > ScriptPath.