Highlighted
New Member.
779 views

Truclient - Pick up different parameter when running on different environments

Jump to solution

Hi All,

I have one Truclient script requiring 10 values from a parameter file to run (param1.dat) on environment #1.

I want to run the same script on another environment, and so I need to pass 10 different values to it related to this new environment.

Do you have any convinient way to do this without chaning the script? Some command line parameters to switch between parameters file would be the best but I do not see the support for it.

Any suggestion?

Thanks,

Camillo

0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Truclient - Pick up different parameter when running on different environments

Jump to solution

Hi,

I suggest creating two parameter files with different content in them but identical structure, meaning the same parameters defined inside them but with different data.

To better articulate it I suggest doing something like:

Param1.dat with  Server_1 , User_1, Password_1 for example

and

Param2.dat with Server_2, User_2, Password_2

The script should get a command line argument that will determine whether you fetch values from the first set of the second one. The command line switch value should be either 1 or 2

The script should have an Evaluate JavaScript step with 

var paramSuffix = TC.getAttr("suffix"); // suffix is the name of the command line argument

Then in all TC.getParam statements you should do something like that...

TC.getParam("Server_" + paramSuffix);
TC.getParam("User_" + paramSuffix);
TC.getParam("Password_" + paramSuffix);

Regards,

Shlomi

View solution in original post

3 Replies
Highlighted
Established Member..
Established Member..

Re: Truclient - Pick up different parameter when running on different environments

Jump to solution

make a different data file with the same parameters and name it something like "param2.dat" and then give different values to the paramters being used in the script. Select this file "Param2.dat" from the drop down list. 

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: Truclient - Pick up different parameter when running on different environments

Jump to solution

Hi,

I suggest creating two parameter files with different content in them but identical structure, meaning the same parameters defined inside them but with different data.

To better articulate it I suggest doing something like:

Param1.dat with  Server_1 , User_1, Password_1 for example

and

Param2.dat with Server_2, User_2, Password_2

The script should get a command line argument that will determine whether you fetch values from the first set of the second one. The command line switch value should be either 1 or 2

The script should have an Evaluate JavaScript step with 

var paramSuffix = TC.getAttr("suffix"); // suffix is the name of the command line argument

Then in all TC.getParam statements you should do something like that...

TC.getParam("Server_" + paramSuffix);
TC.getParam("User_" + paramSuffix);
TC.getParam("Password_" + paramSuffix);

Regards,

Shlomi

View solution in original post

Highlighted
New Member.

Re: Truclient - Pick up different parameter when running on different environments

Jump to solution

Thanks for the reply.

I have also successfully tried this variation on Shlomi solution.

  • create one single param.dat file where each line contains the data for a different environment
  • define a command line parameter 'env'
  • create at the top of the script a Evaluate JavaScript step that will advance the parameter point to the line of values I want to use:
    var env = TC.getAttr("env");
    var i = 0;
    
    switch (env)
    {
      case "dev":
        i = 1;
        break;
      case "st":
        i = 2;
        break;
      default:
        i = -1;
        TC.log("env=" + env + " -> INVALID ENVIRONMENT SPECIFIED!!!", "Error");
    }
    
    
    for (; i > 0; i--) {
      TC.advanceParam("env_url");
      TC.advanceParam("username");
      TC.advanceParam("password");
    }
    
    TC.log("env=" + env + ";url=" + TC.getParam("env_url"), "Warning");
    Thanks,Camillo
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.