Request is not captured with the groovy script showing NULL
Hi All,
I have the below script to generate a log file of a complete Test case however, the request is not at all captured dont know what exactly the issue is :
Below is the script :
import com.eviware.soapui.support.GroovyUtils
import com.eviware.soapui.support.XmlHolder
import jxl.*;
import jxl.write.*
import org.apache.commons.lang.StringUtils
def Time = new Date().format("dd-MMM-yyyy h_mm_ss a")
def directory = testRunner.testCase.testSuite.project.getPropertyValue("Logs")
File fold = new File (directory)
fold.mkdir ()
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
//Project Name:
def ProjectName=testRunner.testCase.testSuite.project.name
//TestSuite Name:
def TestSuiteName=testRunner.testCase.testSuite.name
//Test Case Name:
def TestCaseName=testRunner.getTestCase().getName()
//Creating File
def responseFile = new File (directory,TestCaseName+"_${Time}"+".txt")
def TestCaseDescription = testRunner.testCase.getDescription()
responseFile.append ("Project Name :${ProjectName}\n\n")
responseFile.append ("TestSuite Name :${TestSuiteName}\n\n")
responseFile.append ("TestSuite Name :${TestCaseName}\n\n")
//def testCaseCount = testRunner.testCase.testSuites[TestSuiteName].getTestCaseCount()
def count = testRunner.testCase.getTestStepCount()
for (i=1;i<count;i++){
def StepName = testRunner.testCase.getTestStepAt(i).getName()
if (StepName.toString()== "GetUpdateToken" ||
StepName.toString()== "Delay" ||
StepName.toString()== "Logfile" )
log.info StepName
else if (StepName.toString()== "GetReservation"
|| StepName.toString()== "UpdateReservation_Add_Hotel_Segment")
{
log.info StepName
responseFile.append ("TestStep Name :${StepName}\n")
def requestName = "\n****************REQUEST****************\n\n"
responseFile.append(requestName, "UTF-8")
def request = testRunner.testCase.testSteps[StepName].testRequest.response.getRequestContent()
//log.info request
responseFile.append(request, "UTF-8")
def responseName = "\n\n****************RESPONSE****************\n\n"
responseFile.append(responseName, "UTF-8")
def response = testRunner.testCase.testSteps[StepName].testRequest.response.getResponseContent()
//log.info response.toString()
responseFile.append(response, "UTF-8")
responseFile.append("\n\n")
}
else{
def RQHolder = groovyUtils.getXmlHolder(StepName.toString()+"#Request")
RQHolder.namespaces["xmlns"] = "http://webservices.sabre.com/sabreXML/2003/07"
def nodeRQ = RQHolder.getNodeValue("//xmlns:SabreCommandLLSRQ/xmlns:Request/xmlns:HostCommand")
def RSholder = groovyUtils.getXmlHolder(StepName.toString()+"#Response")
RSholder.namespaces["xmlns"] = "http://webservices.sabre.com/sabreXML/2003/07"
def nodeRS = RSholder.getNodeValue("//xmlns:SabreCommandLLSRS/xmlns:Response")
def Name = testRunner.testCase.testSuite.getName()
responseFile.append (context.expand(StepName.toString()+ "Step Request: ${nodeRQ}\n"))
responseFile.append (context.expand(StepName.toString()+ "Step Response: ${nodeRS}\n\n"))
}
}
In log file the request is showing NULL.