Forum Discussion
cmmi
16 years agoNew Contributor
You know, the moment you start explaning your problems
to others you sometimes get the right answer yourself.
That's what happend here to me, below you can find my updated code which gives me the right answer now. There is only one slight issue. Running the test suit or test case will do just fine, but running only the test step gives me XPath assertion errors. Seems the "afterSubmit" event is not performed prior to the test step assertions in this case, can it be?
to others you sometimes get the right answer yourself.
That's what happend here to me, below you can find my updated code which gives me the right answer now. There is only one slight issue. Running the test suit or test case will do just fine, but running only the test step gives me XPath assertion errors. Seems the "afterSubmit" event is not performed prior to the test step assertions in this case, can it be?
if( submit.response == null )
return
def content = submit.response.responseContent
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def target = context.testCase.getTestStepAt(context.getCurrentStepIndex()).getLabel() + "#Response"
def holder = groovyUtils.getXmlHolder(target)
def payload = holder.getNodeValue("//return[1]/text()")
def xmlid = '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>'
if (payload.startsWith(xmlid)) {
payload = payload.substring(xmlid.length(), payload.length())
}
holder.setNodeValue("//return[1]", payload)
holder.updateProperty()
content = holder.getXml()
content = content.replaceAll(/<!\[CDATA\[/,'')
content = content.replaceAll(/\]\]>/,'')
submit.response.responseContent = content