Forum Discussion

NareshNayini's avatar
NareshNayini
Occasional Contributor
13 years ago

How to get the test case response using groovy?

Hi,

Please let me know on how to get the response of a particular test case using Groovy script?

Thanks in Adv,
Naresh Nayini

2 Replies

  • mkoron's avatar
    mkoron
    New Contributor
    Assuming you have a soap request 'step1' and groovy step in the same test case.
    And response looks like:

    <Envelope>
    <Header/>
    <Body>
    <Service>
    <responseCode>1111</responseCode>
    [...]


    groovy:

    def gu = new com.eviware.soapui.support.GroovyUtils(context);
    def holder = gu.getXmlHolder('step1#Response');
    def respEnvelope = new XmlSlurper().parseText(holder.getXml());


    now you can get field valiue from response with:

    def yourVariable = respEnvelope.Body.Service.responseCode;