I'm firing off a GET request and then using a script assertion to populate a variable:

def sValue = responseHolder.getNodeValue("//URL/url/value")

I want to store the contents of sValue and use it in subsequent test scripts.

I've been trying to get properties working but am having no luck. I suspect that I've missed something embarassingly fundamental.

Can anyone give me a hand with this?

  • Can you please show the sample xml response? It couldn't be working because, xpath might be incorrect.
    – Rao
    Jun 18 '16 at 4:03

Here is how I would do it.

Assuming this in your test case. There is a step which invoke a soap request and gets the response. Add a Script Assertion and below is the script. And what this script does is that it will read the response, checks if it is not a soapfault and extract the required xpath value as you desired and saves it at test case level property, say VALUE_FROM_PREVIOUS_RESPONSE is property name.


import com.eviware.soapui.support.XmlHolder
//asserting if the response is soap fault
assert context.response.toLowerCase().contains('soapfault'), "Response is soap fault"
def holder = new XmlHolder(context.response)
//You need to replace the xpath in below statement
def sValue = holder.getNodeValue('/your/xpath')
//asserting if given xpath has any value
assert sValue, "Xpath does not have any value"
//saving the above value at test case level property VALUE_FROM_PREVIOUS_RESPONSE
context.testCase.setPropertyValue('VALUE_FROM_PREVIOUS_RESPONSE', sValue)

In the next test step request, use the above property where ever you need above response value of previous step. That is known as property expansion.

Say, <yourXmlElement>${#TestCase#VALUE_FROM_PREVIOUS_RESPONSE}</yourXmlElement>

Hope this helps.

  • @dave-m, did it help to resolve the issue or still having the problem?
    – Rao
    Aug 23 '16 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.