06-25-2014 11:14 AM - edited 06-25-2014 11:25 AM
Suppose I have an XPath like this:
Success! Object found.
Now suppose I variablize it:
var q=2; evalXPath("(//a[text()=\""+q+"\"])");
Success! Object found.
Now suppose I wrap it in a for loop:
For (var q=1; q<8; q++) evalXPath("(//a[text()=\""+q+"\"])");
Solved! Go to Solution.
06-25-2014 11:27 AM
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; evalXPath("(//a[text()=\""+w+"\"])");
06-25-2014 12:11 PM
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.
06-30-2014 08:24 AM
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.
06-30-2014 01:51 PM
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.
06-30-2014 03:24 PM
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.
07-02-2014 12:24 PM
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.
07-11-2014 08:24 AM
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?
07-11-2014 09:22 AM - edited 07-11-2014 09:34 AM
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.
07-15-2014 11:26 AM
There is NO REASON to do this.
This worked in 11.52. I used for loops frequently.
07-16-2014 06:14 AM - edited 07-16-2014 06:26 AM
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.
If you haven’t tried it yet, come and join us in our entitled forums at Support Customer Forums
If you find that this or any post resolves your issue, please be sure to mark it as an accepted solution and give Kudos to the author for their assistance.