0
votes

I'm having trouble getting the while controller to work in jmeter.

I've a feeling that I read that it doesn't re-evalute user defined variables, so I am trying to use properties instead.

I start off by using a BSF assertion to set a property called keepLooping

${__setProperty(keepLooping, true)};

This seems to work as it enters the While controller with a condition of

${__property(keepLooping)}

But I cannot for the life of me get it to change that property to something else. I want it to change the property depending on the resulting text of an http request.

So I am using a Regular Expression Extractor to set a variable, which I can see is getting set. Then I am trying to use a BSF assertion to set the keepLooping property on the basis of the variable that I have set. I am using javascript as follows:

log.info("IM IN HERE");
log.info("props is "+props);
//log.info("props keep looping is  "+props["keepLooping"]);
if (${surveyRequired} == false){
    log.info("IM IN HERE 1A and props is "+props);
    ${__setProperty(keepLooping, true)};
    log.info("IM IN HERE 1B");
}
else {
    log.info("IM IN HERE 2A");  
    ${__setProperty(keepLooping, false)};
    log.info("IM IN HERE 2B");
}

I can't figure out how to set the property with javascript - I've tried several things. Can anyone help? Many thanks!

Also can anyone recommend a good resource that negotiates what seem to be the many 'quirks' of jmeter? Many thanks!

2

2 Answers

2
votes

"I've a feeling that I read that it doesn't re-evalute user defined variables" -- I use JMeter 2.9 and it really does. I use user defined variable in order to count number of loops. It looks like: ${__javaScript(${MY_USER_DEFINED_VARIABLE}>0)}. The only one annoying thing is that I have to get value of variable, increment it, cast to string (toString() in Groovy), and then put new value into MY_USER_DEFINED_VARIABLE (by using vars.putObject("MY_USER_DEFINED_VARIABLE",localBSFVariable))

0
votes

Using vars.put or props.put will help, as explained in detailed in detail in this jmeter thread.