Answered question

How to parameterize Variable Type: File in Variable Manager

Hi,

I am running a script to run my test through Command Line. I have a variable called logins (file) type which is .csv. I read my logins and passwords through it.

Is there way I can parameterize my file name value, so that I can change the file when running the script?

Script:
./NeoLoadCmd -project pathToMyProject.nlp
-launch Scenario1 -noGUI -variables env=PROD, logins=variables/LoginCredentials.csv

I am hoping to change logins value to something else next time I run this script. For example change the logins variable value to = LoginCredentials22.csv. Can I do that?

Shahboz S.
Shahboz S.

Shahboz S.

Level
0
56 / 100
points
christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

I recommend you rename the variable "Logins" to "Logins_Prod".

Then, you need to declare an "ENV" constant variable, which value is "Prod" or "Stage" according to the context (you can override in the command line with -variables ENV=Stage

Then you can use:
{"@action":"login","@class":"login","@username":"${logins_${ENV}}.username","@psw":"${logins_${ENV}}.password"}

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful

Other answers

christophe M.
christophe M.

christophe M.

Level
4
5000 / 5000
points
Team

You cannot variabilize the file path. You need to variabilize the calls:

Declare one variable per Environment:
MyFileFor-PROD=LoginCredentials-for-PROD.csv.
MyFileFor-PREPROD=LoginCredentials-for-PREPROD.csv.

then, variabilize all calls:
Login parameter = ${MyFileFor-${ENV}}.Login

Shahboz S.
Shahboz S.

Shahboz S.

Level
0
56 / 100
points

Christophe,

So I declared two variables:

Variable 1: "Logins" contains file loginsProd.csv
Variable 2: "Logins_Stage" contains file loginsStage.csv

Question: How do I run a script in CMD, so I can choose either Variable 1 or Variable 2 for all my login calls in the project?

My current call looks like this:

{"@action":"login","@class":"login","@username":"${loginsProd.username}","@psw":"${loginsProd.password}"}