我想随时(根据我的要求)清除 JMeter JsessionID 变量。
我知道 JMeter CookieManager 中有一个名为“Clear Cookie on each Iteration”的复选框选项。
但它会在每次迭代时清除 session ,而我想在迭代中随时清除它。
我如何在 JMeter 中做到这一点?
最佳答案
你可以,只需添加后处理/前处理 beanShell 并使用此代码
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
for (int i=0;i<manager.getCookieCount();i++){
Cookie cookie = manager.get(i);
//remove a cookie
if (cookie.getName().equals("BAD_COOKIE")){
sampler.getCookieManager().remove(i);
}
}
关于testing - 如何按需清除JMeter中每个Thread(用户)的JSESSIONID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12707635/