I am facing an issue on saving the value from response to a property using assertion
My Response
HTTP/1.1 201 Created
Date: Fri, 09 Oct 2020 15:29:59 GMT
Content-Type: text/plain
X-Application-Context: provisioningContext,AESPassword:oidc,multiTenant:8086
TraceID: f81edfd6-a7a1-41d4-b3aa-602287523f07
Content-Length: 32
8a74833d746c689a01750dfbada4709f
I need to save 8a74833d746c689a01750dfbada4709f to a property called Id in the testcase, so that i can use it in the next teststep.
Tried -
As there is no name space i couldn't trace the value so used *
def gutils = new com.eviware.soapui.support.GroovyUtils( context );
def responseHolder = gutils.getXmlHolder(messageExchange.responseContentAsXml.toString());
def token = responseHolder.getNodeValue("//*:*")
def testCase = messageExchange.modelItem.testCase
testCase.getTestStepByName("Properties").setPropertyValue("id",token);
I am new to SoapUI so can anyone help me on how to resolve this?
Hey iotmail9
so you just want to save an HTTP header value to a property for later use?
I cant see which header the value '8a74833d746c689a01750dfbada4709f' is associated with - when I've done this before I've used either a groovy script or a script assertion as follows:
Script assertion option:
//Script assertion uses messageExchange.modelItem rather than testRunner //Takes one of the elements of the response Header def value = messageExchange.modelItem.testStep.testCase.testSteps["REST TestStepName"].testRequest.response.responseHeaders["headerName"] //Read this value into a parameter - writes the header value into the Properties test step def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) groovyUtils.setPropertyValue("Properties", "header",value[0]) //the above grabs the value associated with the 'headerName' header and saves it to the 'header' property within the Properties test step
Groovy Script option:
//Groovy Script uses testRunner rather than messageExchange.modelItem //Takes one of the elements of the response Header def value = testRunner.testCase.testSteps["REST TestStepName"].testRequest.response.responseHeaders["headerName"] //Read this value into a parameter - writes the header value into the Properties test step def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) groovyUtils.setPropertyValue("Properties", "header",value[0]) //the above grabs the value associated with the 'headerName' header and saves it to the 'header' property within the Properties test step
ta
rich