I am trying to clear cookies programmatically using the following code. But it is completely removing cookies and acting as "no cookies" from the second iteration. I want to store the cookies for the current iteration and from the next iteration, it should start as fresh again. Can you suggest any modifications here?
My requirement is just to delete cookies after every iteration. HTTP cookie manager is not working(i tried at both test plan and thread group level). So trying programatically.
import org.apache.jmeter.protocol.http.control.Cookie;
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.commons.lang3;
CookieManager manager = ctx.getCurrentSampler().getCookieManager();
for (int i = 0; i <= manager.getCookieCount(); i++)
{
manager.clear();
ctx.getCurrentSampler().setCookieManager(manager);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…