【问题标题】:Unable to print the response value to a output file in Jmeter 3.2 using Bean Shell Processor无法使用 Bean Shell 处理器将响应值打印到 Jmeter 3.2 中的输出文件
【发布时间】:2017-07-19 08:26:36
【问题描述】:

我想使用 Bean Shell 处理器将 Booking 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 错误 o.a.j.u.BeanShellInterpreter:错误 调用 bsh 方法:eval 源文件:内联评估:ID = vars.get("BookingID"); f = new FileOutputStream("C:/BookingID.csv", 真的); . . . '' : 对象构造函数 2017-07-18 09:28:11,836 WARN o.a.j.e.BeanShellPostProcessor:BeanShell 脚本中的问题: org.apache.jorphan.util.JMeterException:调用 bsh 方法时出错: eval 源文件:内联评估:ID = vars.get("BookingID"); f = new FileOutputStream("C:/BookingID.csv", true); . . . '' : 目的 构造函数

【问题讨论】:

    标签: java jmeter jmeter-3.2


    【解决方案1】:

    将 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 或记事本的程序中打开文件并且它被锁定,退出编辑此文件并重试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-19
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 2014-04-29
      • 1970-01-01
      相关资源
      最近更新 更多