jmeter - 在 JMeter 中使用 Beanshell 采样器将变量写入 txt/csv 文件
问题描述
我的要求是使用在不同步骤中使用的 2 个 Beanshell 采样器写入两个值,在一行中并用逗号分隔但第二个变量写在新行上
我在不同的步骤中有两个不同的 Beanshell 采样器。第一个捕获变量 1 并将其写入文件 第二个捕获变量 2 并将其写入文件
第一个代码:
String path= FileServer.getFileServer().getBaseDir() + "//P_IssuePolicy.txt";
SubmissionNum= vars.get("CP_SubmissionNumber");
EMailID= vars.get("P_emailID");
f = new FileOutputStream(path, true);
p = new PrintStream(f);
this.interpreter.setOut(p);
p.println(EMailID+","+SubmissionNum);
f.close();
第二个代码:
String path= FileServer.getFileServer().getBaseDir() + "//P_IssuePolicy.txt";
Policynumber= vars.get("CP_Policynumber");
f = new FileOutputStream(path, true);
p = new PrintStream(f);
this.interpreter.setOut(p);
p.println(","+Policynumber);
f.close();
预期结果:
abc@email.com,12345601,12345602
实际结果:
abc@email.com,12345601
,12345602
解决方案
而不是println
添加新行使用打印
p.print(EMailID+","+SubmissionNum);
推荐阅读
- azure - 如何为 Azure 函数指定 web.config 中通常包含的内容?
- php - 使用 $_FILE 图像上传更新 SQL Server 表中的 VARBINARY(MAX) 列
- angularjs - 我们可以将 es6 与 AngularJS 一起使用吗
- selenium - 无法在硒的文本框中输入数字
- javascript - 打开授权代码流弹出窗口,获取令牌并在同一个按钮单击时使用它
- c# - KfxReleaseScript 中的 LogError()
- scala - 组织与类型关联的 Scala 隐式
- selenium - 如何在没有 AutoIt 的情况下在 selenium 中下载 chrome 文件时处理“保留”和“丢弃”选项?
- java - Soap 消息级安全性
- asp.net - EF Core 迁移:无法加载程序集“AssemblyName”