Forum Discussion

Sirisha2020's avatar
Sirisha2020
Contributor
4 years ago
Solved

i want to save REST Response on test case level to a notepad or to any other file using soap ui

  • HimanshuTayal's avatar
    4 years ago

    Sirisha2020 :

     

    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");
    	}
    }