sharmanehaynr's avatar
sharmanehaynr
New Contributor
7 years ago
Status:
New Idea

Ability to reuse the script variables in keywords

Previously we were writing the code in script files and we had a lot of global variables in each scrip with object xpaths and we were able to use them across scripts very easily.

 

Now we have changed our approach to "Keyword driven" but there is no way in Testcomplete to reuse the global variables from scripts in keywords.

 

Currently we came up with the appraoch where we did all USEUNITS in  a script file and wrote a function GetScriptVariable(),which returns the variable value by evaluating it:

 

function GetScriptVariable(scriptFileName, variableName )

{

  return eval(scriptFileName+"."+variableName);

}

 

Now we are thinking of dissolving this script file and it makes no logic to keep it only to support this one function.

 

There should be some way in keywords tests to reuse script variables.

3 Comments

  • I am familiar with the project level variables and how to use them b/w scripts and keywords.

    The main issue is the variables like :

    var mSerial = "\\td\tr.." which are defined as global in scripts.

    There is no way to use them directly in keyword tests.

     

    Our scripts have 100's of global variable xpath defined in scripts and we cannot move all those variables to project suite variables.

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    I think the solution you came up with is your best option.  Making Keyword Tests more script-like might not be high on the backlog simply because the Keyword Tests are designed for those who don't code much or at all.  

     

    Then again, who knows?  Get all your friends to give kudos and maybe it will get some attention!  :)