Using Jmeter 2.12, what could cause the cookies to fail to reset during a JMeter Loop Controller? I've tried everything I can think of, but each time through the loop, one of the cookies from a previous login still remains. It doesn't seem to actually clear the cookies.
Here is how I put together my loop:
Thread Group 1
-- Loop Controller (3x)
-- Simple Controller
-- HTTP Header Manager
-- HTTP Cookie Manger (with 'Clear cookies each iteration?' enabled)
-- BeanShell sampler - with code that tries to clear all cookies
-- HTTP /login (gets cookies and auth headers)
-- ... various HTTP Samplers ...
-- HTTP /logout
I tried adding a Beanshell sampler with this code (as shown above) but it doesn't seem to do anything:
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.HeaderManager;
CookieManager cManager = sampler.getCookieManager();
cManager.clear();
HeaderManager hManager = sampler.getHeaderManager();
hManager.clear();
if you leave the “Condition” blank or set it to LAST, the loop will break if the last sampler under the While Controller is not be successful. The same applies to the Variables and Properties. The While Controller will loop its children until the Variable or Property specified in “Condition” will result in “true”.
The Loop Controller is a way of moving the number of iterations your samplers run away from the Thread Group to provide more control over your scenario profile. Let's look at the controller. JMeter Loop Controller. If we take a Test Plan that manages the loop count using the Thread Group.
Ok, I figured out the problem. Even though the 'HTTP Cookie Manager' has an option called 'Clear cookies each iteration', the 'iteration' it speaks of does not include a Loop Controller. What it refers to is the 'Thread Group' iterations/loops only. This was not clear and I wasted half a day until I figured this out. Wouldn't have been confusing if the checkbox said 'Clear cookies each Thread Group iteration' instead. Very disappointing.
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