I have a few HTTP Request Samplers that I would only like to execute when a certain condition has been met. What I have done is added a BeanShell PreProcessor to the HTTP Request Sampler with the following code
if (${getTeamName}.equals("Test Team") == true)
{
HTTPSampler.setEnabled(false);
}
If the value of getTeamName is Test Team then I want to disable that HTTP Request Sampler, as it doesn't have to be executed then. However it looks like that currently doesn't work.
Is there any one who knows what I'm doing wrong here, or a suggestion to what I should do?
As per JMeter Performance and Tuning Tips guide:
But of course ensure your script is necessary and efficiently written, DON'T OVERSCRIPT
Why not just to use If Controller like:
"${getTeamName}" != "Test Team"
If ${getTeamName}
will be Test Team
child sampler(s) won't be executed.
While using beanshell, access variables using vars.get("VARNAME")
if (vars.get("getTeamName").equals("Test Team") == true)
{
sampler.setEnabled(false);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With