我想使用 Bean Shell 处理器将预订 ID 的值打印到 JMeter 中的输出文件。 我的代码:
ID = vars.get("BookingID");
f = new FileOutputStream("C:/BookingID.csv", true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(ID);
f.close();
我 我使用的是 JMeter 3.2 版本。
当我运行此代码时,我收到错误:
2017-07-18 09:28:11,836 ERROR o.a.j.u.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: ID = vars.get("BookingID"); f = new FileOutputStream("C:/BookingID.csv", true); . . . '' : Object constructor 2017-07-18 09:28:11,836 WARN o.a.j.e.BeanShellPostProcessor: Problem in BeanShell script: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: ID = vars.get("BookingID"); f = new FileOutputStream("C:/BookingID.csv", true); . . . '' : Object constructor
最佳答案
将 BeanShell PostProcessor 添加到请求中。该代码将按原样工作
ID = vars.get("BookingID");
f = new FileOutputStream("C:/BookingID.csv", true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(ID);
f.close();
您可能存在写入 C:\的权限问题,请通过尝试创建文件来检查它,或者您在 Excel 或记事本程序中打开该文件并且该文件已锁定,请停止编辑该文件并重试。
关于java - 无法使用 Bean Shell 处理器将响应值打印到 Jmeter 3.2 中的输出文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45184963/