【问题标题】:Facing an error while writing the info in local file through Jmeter通过 Jmeter 在本地文件中写入信息时遇到错误
【发布时间】:2019-06-20 11:11:56
【问题描述】:

即使我也更改了路径,我也尝试了以下脚本,但我仍然面临同样的问题。

 basecost=vars.get("_baseCost");    
                 File=new FileOutputStream ("‪‪‪C:/Rajesh/Automation Stuff/rajesh.txt",true);    
             P=new PrintStream(File);    
             this.interpreter.setOut(P);    
             print(basecost);    
             File.close();    

低于错误
错误 o.a.j.u.BeanShellInterpreter:调用 bsh 方法时出错:eval 源文件:内联评估:``File=new FileOutputStream ("C:/Rajesh/Automation Stuff/rajesh.txt",true); P = 。 . . '' : 目的 构造函数

【问题讨论】:

标签: jmeter beanshell jmeter-3.2 jmeter-5.0


【解决方案1】:

在调查此问题时,我发现您的代码下面的行中有一些编码字符是其失败的原因。

File=new FileOutputStream (

我是如何找到它的?

打开 notepad++ 并将代码粘贴到其中。转到“编码”并选择“在 ANSI 中编码”

当您单击在 ANSI 中编码时,您将在代码的第二行(其中 Jmeter 抛出错误)中看到一些编码字符(见下面的屏幕截图)。删除那些编码字符并使用 Jmeter Bean-shell 中的代码。现在可以正常使用了。

【讨论】:

  • 非常感谢。它现在正在工作。我尝试了太多方法,但我没有找到这个。非常感谢你让我的一天更轻松。
【解决方案2】:

不要使用 Beanshell 编写脚本,这是一种性能反模式,since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language

示例代码:

new File("‪‪‪C:/Rajesh/Automation Stuff/rajesh.txt") << vars.get("_baseCost")

更多信息:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-08
    • 2013-12-05
    • 2021-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多