mardi 20 octobre 2015

If Condition for a Random Variable using JavaScript in Neoload Tool

I previously worked on LoadRunner and I find scripting in Neoload to be a great pain. Also I am not that good in JavaScript.

I am just trying to capture a stack variable (name).

Ex. name_1, name_2, name_3, name_4

So I need to randomize and choose from 4 of the above.

Lets say, name_${randInt}. I'm ok till this.

Now, I need to check the value for this variable,

Say for ex. name_${randInt} has the value 'Checked'

Now I need a If condition to check if name_${randInt} = 'Checked'

If Yes another variable, myVar = on, else myVar = off

And this myVar I should use to insert back in my script.

How can this be done?

Sample code is given below,

var check = context.variableManager.getValue("ERRP_CheckUnCheck");

if (check==null)
{
    computedValue = 'on'
}
else
{
    computedValue = null
}

context.variableManager.setValue("computedVar1",computedValue);

Aucun commentaire:

Enregistrer un commentaire