当我使用BeanShell PostProcessor删除标题时,出现了问题 我的代码:
import org.apache.jmeter.protocol.http.control.Header;
sampler.getHeaderManager().removeHeaderNamed("Authorization");
异常:
2017/05/18 15:24:52 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManage . . . '' : Attempt to resolve method: getHeaderManager() on undefined variable or class name: sampler
2017/05/18 15:24:52 WARN - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ``import org.apache.jmeter.protocol.http.control.Header; sampler.getHeaderManage . . . '' : Attempt to resolve method: getHeaderManager() on undefined variable or class name: sampler
有人帮助我
答案 0 :(得分:2)
您在PostProcessor中没有sampler
简写,如果您需要从上一个采样器中删除标题,相关代码应如下所示:
ctx.getCurrentSampler().getHeaderManager().removeHeaderNamed("Authorization");
ctx
是JMeterContext班级实例的简写sampler
简写