Reputation: 29
I am using Apache Jmeter. I have a script with different controllers inside a globalNav. I would want to make it so that if the condition in my first if controller is true, i send a certain cookie to all other requests in the other controllers. If the condition in the other if is true, i send another type of cookie to the other controllers
I know my if condition is correct because i tested it in its own controller but i can't seem to make it work globally. Please note that i'm new to Jmeter. Thanks
Upvotes: 0
Views: 186
Reputation: 168002
I don't think it will work this way, if you don't have any Samplers under the If Controller the HTTP Cookie Manager will be silently ignored. Moreover according to JMeter Scoping Rules the cookie will be created only for the HTTP Request samplers which are under the particular If Controller.
I would rather go for JSR223 PreProcessor and the code like:
if (vars.get('somevar') == 'foo') { // change it to your condition like in the If Controller
sampler.getCookieManager().add(new org.apache.jmeter.protocol.http.control.Cookie("my-cookie", "foo", "example.com", "/", false, System.currentTimeMillis() + 10000))
} else {
sampler.getCookieManager().add(new org.apache.jmeter.protocol.http.control.Cookie("my-cookie", "bar", "example.com", "/", false, System.currentTimeMillis() + 10000))
}
Upvotes: 1