I have seen many examples but none seem to work.
This is what I have setup:
I'm using a foreach to loop through my variables and have Cookie Manager use them:
I want the beanshell to clear the cookies in the cookie manager on each loop so they get re-added from my vars, but I can't seem to access it.
I tried the following:
import org.apache.jmeter.protocol.http.control.Cookie;
import org.apache.jmeter.protocol.http.control.CookieManager;
manager = sampler.getCookieManager();
That gives me this error:
Attempt to resolve method: getCookieManager() on undefined variable or class name: sampler
I tried doing this:
CookieManager cManager = ctx.getCurrentSampler().getCookieManager();
But that gives me this error:
Typed variable declaration : Error in method invocation: Method getCookieManager() not found in class'org.apache.jmeter.protocol.java.sampler.BeanShellSampler'
Edit: So as per a suggested solution I tried this:
And then this:
But that gives me this error:
2017/10/13 12:26:31 ERROR - jmeter.extractor.JSR223PostProcessor: Problem in JSR223 script JSR223 PostProcessor javax.script.ScriptException: java.lang.NullPointerException: Cannot invoke method clear() on null object
Don't use Beanshell because of Performance and it will be removed in future versions.
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager cm = sampler.getCookieManager();
cm.clear();
This is what it should look like