如何将特定数据从响应数据保存到CSV文件 [英] How to save specific data from response data to csv file
问题描述
在我的webservices测试计划中,我正在发送SOAP请求以创建用户,并且它在响应数据中发送回用户名和唯一ID.我想将该用户名和唯一标识保存到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屋!