Forum Discussion
nmrao
12 years agoCommunity Hero
Here is the understanding from the topic description of the case:
Both steps in the same test case.
Steps look in the following order
1. create request
2. groovy script
3. retrieve request
And you need to get an element value from response of step 1, and use the value in an element of step 3 request.
Groovy script may look like this
In the step3, use as mentioned below, do not have to set separately
retrieve request goes here
...
.....
<orderId>${#TestCase#ORDERID}</orderId>
.....
....
Both steps in the same test case.
Steps look in the following order
1. create request
2. groovy script
3. retrieve request
And you need to get an element value from response of step 1, and use the value in an element of step 3 request.
Groovy script may look like this
//The following steps are to retrieve required element value from create response
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def currentStep = context.testCase.getTestStepAt(context.getCurrentStepIndex())
def prevStep = testRunner.testCase.findPreviousStepOfType(currentStep,com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep.class)
def response = prevStep.getTestRequest().getResponse()
def streamText = response.getContentAsString()
def responseHolder = groovyUtils.getXmlHolder(streamText)
/* Below are samples, please use as per your response*/
//define if there any namespaces from create response and replace values accordingly, otherwise ignore it
//responseHolder.namespaces["ns"]="http://www.yourcompany.com/service"
//retrieving required node value using xpath
//def orderId = responseHolder.getNodeValue("//ns:orderID/text()")
//Now set this retrieved value as property at test case level, so that it can be used in the next step
context.testCase.setPropertyValue('ORDERID',orderId)
In the step3, use as mentioned below, do not have to set separately
retrieve request goes here
...
.....
<orderId>${#TestCase#ORDERID}</orderId>
.....
....