Hi everyone,
I started using the free version of SOAP UI recently and was wondering how to properly implement a loop to get the soap Response and Request of every test step and collate them into a file. I also looked into the API documentation but I was lost and I don't know which one to use. Anyway, I was able to retrieve a specific teststep response and request using the code below.
def response = context.expand( '${TestStepName#Response}' ) def rawrequest = context.expand( '${TestStepName#RawRequest}' ) def soapresponse = 'c:/users/Desktop/soapoutput/a.doc' def soaprawrequest = 'c:/users/Desktop/soapoutput/b.doc' def f = new File(soapresponse) def g = new File(soaprawrequest) f.write(response, "UTF-8") g.write(rawrequest, "UTF-8")
I also searched the net and found this snippet regarding the teststep loop
//Define the object for the collection of requests in the soapUI test case def soapuiRequests = testRunner.testCase.getTestStepsOfType(com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep ) //Groovy Script to loop through each requests in the test case. soapuiRequests.each{ //Creating file name using current date and time //Writing soapUI response to the file inputFileResponse.write(context.testCase.getTestStepByName(it.name).getProperty('response').value) //Writing soapUI request to the file inputFileRequest.write(context.testCase.getTestStepByName(it.name).getProperty('request').value) Date startTime = new Date(); def cur_Time = startTime.getMonth() + "_" + startTime.getDate(); cur_Time = cur_Time + "_" + startTime.getHours() + startTime.getMinutes() +startTime.getSeconds() def fileName = it.name + "_" + cur_Time def inputFileRequest = new File("C:/Users/Desktop/soapoutput"+ "Request_" + fileName+".txt") def inputFileResponse = new File("C:/Users/Desktop/soapoutput"+ "Response_" + fileName+".txt") }
There were no problems during the execution of the script but the file is not generated. This is the response after execution.
Any help will be much appreciated.