Forum Discussion
geoffcamp
15 years agoContributor
Hiya,
How about a groovy script along the following lines:
This allows you to determine the folder you want to save in a property, and the same for the root part of the filename (in your case 01_AK_001, 02_AL_001...) - you can read this into the appropriate property from elsewhere (or you could read it in directly here and bypass the Property completely if you want).
It adds a datetime stamp so if you run the same request multiple times the requests and responses don't overwrite each other.
How about a groovy script along the following lines:
def name = context.expand( '${Properties#Filename}' )
def location = context.expand( '${Properties#Location}' )
def getResponseFilename(name) {
date = new Date()
dateFormat = new java.text.SimpleDateFormat('yyyyMMdd-kkmmss')
shortDate = dateFormat.format(date)
respFilename = shortDate + "-" + name + "-response.xml"
}
def getRequestFilename(name) {
reqFilename = shortDate + "-" + name + "-request.xml"
}
def file = new PrintWriter (location + getResponseFilename(name))
def Response = testRunner.testCase.testSteps["Request"].testRequest.response.contentAsString
file.println(Response)
file.flush()
file.close()
def file2 = new PrintWriter (location + getRequestFilename(name))
def Request = context.expand( '${Request#Request#//soapenv:Envelope[1]}' )
file2.println(Request)
file2.flush()
file2.close()
This allows you to determine the folder you want to save in a property, and the same for the root part of the filename (in your case 01_AK_001, 02_AL_001...) - you can read this into the appropriate property from elsewhere (or you could read it in directly here and bypass the Property completely if you want).
It adds a datetime stamp so if you run the same request multiple times the requests and responses don't overwrite each other.
Related Content
- 7 years ago
- 8 years ago