Forum Discussion

dhanadmr's avatar
dhanadmr
New Contributor
8 years ago

Need Help: SOAP UI automation

I want to automate below scenario using groovy script..please suggest.

 

I have multiple request files, After execution of each request I have to copy the response(few tags) and I have to to use in next request while execution.

1 Reply

  • nmrao's avatar
    nmrao
    Champion Level 3

    Let us take one step at a time.
    Assuming there is a test case with step1 and step2

    Step1 is executed, and you need to extract some data out of its response and pass it to Step2.

    Is that what you want in the essence?

    Now, how to retrieve required data from step1 response. Assuming there is a valid xpath //*:element

    You can use script assertion:

     

    //Script assertion for step1
    
    import com.eviware.soapui.support.XmlHolder
    def xml = new XmlHolder(context.response)
    //Modify the xpath as you needed
    def elementValue = xml.getNodeValue("//*:element/text()")
    assert elementValue, "Value is null or empty"
    //save the retrived value to custom properties of test case,
    //so that it can be used in the further steps
    context.testCase.setPropertyValue('ELEMENT_DATA', elementValue)


    Then you can use property expansion for tags where data needs to be changed in step2 request.
    Please see documentation:
    https://www.soapui.org/scripting---properties/property-expansion.html

    for eg:
    <element>${#TestCase#ELEMENT_DATA}</element>