I have a situation where I need to call a certain feature (which has validations) multiple times within a loop. Currently, my code successfully calls the feature 3 times.
* def xxx =
"""
function(times){
for(i=0;i<times;i++){
karate.call('classpath:api/test/hello.feature');
}
}
"""
* call xxx 3
Within the feature file being called, the first few lines of code look like this:
* def someVariable = 0;
* def index = response[someVariable]
* some other code
My challenge is that I need the value of someVariable
to change based on the index i
. In other words, during the loop iterations, someVariable
should be updated accordingly - e.g. * def someVariable = 0;
for the first iteration, * def someVariable = 1;
for the second iteration, and so on.
I'm seeking advice on how to achieve this. Can I manipulate this variable within the JavaScript loop? Is there a way to utilize the "__loop" functionality to address this issue? Any help or tips would be greatly appreciated. Thank you in advance.