Solved
Forum Discussion
HimanshuTayal
Community Hero
Hope below code will help you out in saving response to txt file, it will work in tear down script of test case:
import groovy.json.JsonOutput;
testCase.testStepList.each{
type = it.config.type
name = it.name
response = it.getPropertyValue("Response")
if(type == "restrequest"){
def pretty = JsonOutput.prettyPrint(response);
def responseFile="F://testing//"+name.toString()+"__response.txt";
def rsfile = new File(responseFile);
rsfile.write(pretty, "UTF-8");
}
}
sonya_m
4 years agoSmartBear Alumni (Retired)
- Sirisha20204 years agoContributor
Hi Himanshu,
i am able to write the response to a document. But i am trying to update the request to a separate word document it is not saving the request along with the time stamp to the word document. Please find the code as below :
def rawRequest = JsonOutput.prettyPrint(request);
def file1 = new File("C://Users//appu//Desktop//proj//groovy1.doc");
file1.write (rawRequest,"UTF-8");I tried various ways to get the request but no luck. Also i want to save request and response along with time stamp.
Thanks.