gpt4 book ai didi

java - 无法使用 Bean Shell 处理器将响应值打印到 Jmeter 3.2 中的输出文件

转载 作者:行者123 更新时间:2023-11-30 06:36:08 27 4
gpt4 key购买 nike

我想使用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com