如何将响应数据中的特定数据保存到 csv 文件 [英] How to save specific data from response data to csv file
问题描述
在我的网络服务测试计划中,我发送 SOAP 请求来创建用户,它在响应数据中发回用户名和唯一 ID.我想将该用户名和 uniqueid 保存到 CSV 文件中.
In my webservices test plan, I am sending SOAP request to create user and it sends back username and unique id in the response data. I want to save that username and uniqueid into a CSV file.
谁能告诉我我怎样才能做到这一点?
Could anyone let me know how can I achieve that?
推荐答案
您可以使用 Regex 后处理器提取数据并将其保存到变量中.
You can extract data using Regex post processor and save it to a variable.
简单的数据写入器、灵活的数据写入器、将结果保存到文件所有这些都可以写入预定义的变量、以固定或少量可自定义格式对文件的响应,但不允许您编写自定义变量.
Simple data writer, Flexible data writer, Save results to a file all these can write predefined variables, responses to a file in a fixed or little bit customizable format but won't let you write your custom variables.
要将其写入文件,您需要使用 Beanshell 处理器.示例代码是,
For writing it to a file you need to use Beanshell processor. Sample code would be,
username = vars.get("username");
password = vars.get("password");
f = new FileOutputStream("/path/user_details.csv", true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(username + "," + password);
f.close();
这篇关于如何将响应数据中的特定数据保存到 csv 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!