Forum Discussion

nedbacan's avatar
Frequent Contributor
4 years ago

Calling variable from another script

Can someone help me understand how to pass a variable to another test using JAVA SCRIPT in TEST COMPLETE?   How can I create another script (Unit2) that will use the value stored in MyFolderName cr...
  • BenoitB's avatar
    4 years ago



    I advice you to create a global object holding all of your variables and then using it by Globals.myvariable.


    file 1: globals.js


      Globals = {};

      Globals.myFolderName = "d:\\rootdirectory\\";


    file 2 : unit1.js

    //USEUNIT globals


    Globals.myFolderName = "c:\\temp\\";


    file 3 :  unit2.js

    //USEUNIT globals

    //USEUNIT unit1


    Log.Message("My folder is "  + Globals.myFolderName);  // -> c:\temp