can not get test step response in groovy
Hello,
My groovy code is as below.
I can get request, while fail to get response.
The error is
org.apacge.xmlbeans.XmlException: error: unexpected end of file after null
error at line: xx
The test step that currentStep points to has been executed and has request/reponse.
if I change variable
def response=context.expand('${${currentStep.name}#response}')
to the real test step name
def response=context.expand('${Additional#response}') // additional is the test step name
The groovy script runs well.
My questions
1. Why can I not get the response?
2. If the test step name has space, like "Additional code", how to make it work in the context.expand. I have tried " " and ' ', they don't work.
--------------------
import com.eviware.soapui.support.XmlHolder
import com.eviware.soapui.impl.wsdl.testcase.WsdlTestRunContext
import groovy.sql.Sql
import oracle.jdbc.driver.OracleTypes
import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep
def currentStep = testRunner.testCase.getTestStepAt(6)
log.info "currentStep.name: " + currentStep.name
// get the hold of request
def request=context.expand('${${currentStep.name}#request}')
log.info " request: " + request
def xmlreq=new XmlHolder(request)
// get the hold of response
def response=context.expand('${${currentStep.name}#response}')
log.info " response: " + response
def xmlres=new XmlHolder(response) // error occurs here
Thanks for your kind help in advance.
Get my answer from the post.
Now variable works well to when I try to get the reponse, while I still don't know the reason why I need to set different variables to get response/ request