Suppose I have an XPath like this:
Success! Object found.
Now suppose I variablize it:
Success! Object found.
Now suppose I wrap it in a for loop:
For (var q=1; q<8; q++)
Go to Solution.
And just in case you are wondering, even setting a totally different variable inside the loop doesn't help - it still won't evaluate:
var w = 1;
Upon further review, variables will not evaluate if the object is inside of ANYthing. If block, For block, Function block, anything. As soon as you take it out of the block, it works fine.
Am I missing something here? Right now I have to use
var iteration = ArgsContext.LR.getParam("Iteration");
to identify my object, then loop using the entire Action.
Please let us know what is the current version of LoadRunner?
I need to investigate about this and let you know about any valuable information.
Yes, this is LR12.It seems to be happening when you drop a For Loop in from the Toolbar, then drop steps in. I finally got it to work if you select a block of steps and right-click and surround with a For Loop.
My mistake - it wasn't an evalXPath, it was just a regular variable substution.Yeah, this is broken, pretty sure. I used to be able to do this.If someone can disprove me and tell me how stupid I am being, I will be gracious. But I need this to work, fast.
So, what youre saying is:
1. Set up a for loop *which uses a perfectly accessible variable*
2. Instantiate a LoadRunner parameter
3. Set that parameter to 1
4. Perform the steps
5. Increment the parameter manually
6. Finish the loop
Is that what we are saying here?
Please create a parameter with a set of values (like 1,2,3,4...), change the Update value on to "Each Occurrece", loop the step which has evalXPath.
Please check the sample script, it may help.
There is NO REASON to do this.This worked in 11.52. I used for loops frequently.
Have you tried using ArgsContext.i where i is the variable used in the for loop.
I have made some test in my LoadRunner 12 environments with the following line of code and I do not receive error messages.
In your case it should be
if in the for loop you are using q as an iteration variable.
Please make sure that you are using only English letters in the function as it can also cause issues.Please see the following thread
Please try it and let us know the outcome.
Thank you in advance.
Vesela, thank you for carefully researching the issue and replying only when you had the correct answer.