mchelikani
12 years agoContributor
How to Get Handle of Request Submitted
Folks,
I have a testcase with multiple test steps.
Test Step1 : Get Some Values from Data Source ( Ex:Excel)
Test Step2: Http Request with body as xml which would have values from datasource.
Test Step3: Save Request and Responses to local file.
When the request is being submitted it is submitted with the variables replaced from datasource but when I save the request it gets saved with variables.
I want to get handle to the request that gets submitted. Please help.
Groovy Script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def lastResult = testRunner.getResults().last()
def lastResultName = lastResult.getTestStep().getLabel().toString()
def request = groovyUtils.getXmlHolder(lastResultName + "#Request")
def response = groovyUtils.getXmlHolder(lastResultName + "#Response")
//def response = groovyUtils.getXmlHolder(testStepResult.testStep.Response)
def resultsFolderPath = context.expand( '${resultsPath}' )
def testCaseName = testRunner.testCase.name
log.info("Request..."+request.getXml())
log.info("Response..."+response.xml)
log.info("resultsFolderPath..."+resultsFolderPath)
def filePath = resultsFolderPath
def requestFileSuffix = "_RQ.xml"
def responseFileSuffix = "_RS.xml"
def fileName = ''
if(testCaseName){
fileName = fileName + testCaseName
}
if(testName){
fileName = fileName +"_" + testName
}
if(hotel){
fileName = fileName + "_" + hotel
}
if(lastResultName){
fileName = fileName + "_" +lastResultName
}
def testcaseRequest = new PrintWriter(filePath + fileName + requestFileSuffix )
def testcaseResponse = new PrintWriter(filePath + fileName + responseFileSuffix )
testcaseRequest.println( request.xml)
testcaseResponse.println( response.getXml())
testcaseRequest.flush()
testcaseRequest.close()
testcaseResponse.flush()
testcaseResponse.close()
I have a testcase with multiple test steps.
Test Step1 : Get Some Values from Data Source ( Ex:Excel)
Test Step2: Http Request with body as xml which would have values from datasource.
Test Step3: Save Request and Responses to local file.
When the request is being submitted it is submitted with the variables replaced from datasource but when I save the request it gets saved with variables.
I want to get handle to the request that gets submitted. Please help.
Groovy Script:
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def lastResult = testRunner.getResults().last()
def lastResultName = lastResult.getTestStep().getLabel().toString()
def request = groovyUtils.getXmlHolder(lastResultName + "#Request")
def response = groovyUtils.getXmlHolder(lastResultName + "#Response")
//def response = groovyUtils.getXmlHolder(testStepResult.testStep.Response)
def resultsFolderPath = context.expand( '${resultsPath}' )
def testCaseName = testRunner.testCase.name
log.info("Request..."+request.getXml())
log.info("Response..."+response.xml)
log.info("resultsFolderPath..."+resultsFolderPath)
def filePath = resultsFolderPath
def requestFileSuffix = "_RQ.xml"
def responseFileSuffix = "_RS.xml"
def fileName = ''
if(testCaseName){
fileName = fileName + testCaseName
}
if(testName){
fileName = fileName +"_" + testName
}
if(hotel){
fileName = fileName + "_" + hotel
}
if(lastResultName){
fileName = fileName + "_" +lastResultName
}
def testcaseRequest = new PrintWriter(filePath + fileName + requestFileSuffix )
def testcaseResponse = new PrintWriter(filePath + fileName + responseFileSuffix )
testcaseRequest.println( request.xml)
testcaseResponse.println( response.getXml())
testcaseRequest.flush()
testcaseRequest.close()
testcaseResponse.flush()
testcaseResponse.close()