Forum Discussion

kirankumar_sk's avatar
kirankumar_sk
Occasional Visitor
9 years ago
Solved

How to extract value from response, compare it, write result as pass/fail to csv with Groovy script?

Hi I am using SOAP UI 4.6.0 - I have a webservice (currency converter from webservicex.net) - I have a TestStep with request XML and a Groovy script. - The input values to the Request XML are passed...
  • nmrao's avatar
    9 years ago

    Coming to the issue, you can do it in multiple ways using assertion.

     

    You can select the type of assertion that you are comfortable with.

    Here are the possibles in this case.

     

    1. Contains Assertion: You can provide the current expected value in the expected place holder like ${#TestCase#EXP_PROP} (use appropriate variable that you were setting in the ReadNextLine step
    2. Script Assertion: You can use this if you are comfortable with groovy scripting. Here you will be able to read the response value using
      def holder = new XmlHolder( messageExchange.responseContentAsXml )
      //use xpath according to your response, and expected property name
      assert holder["//ns1:RequestId"] == context.testCase.getPropertyValue('EXP_PROP')
    3. Xpath Assertion: You can this as well using xpath and expected value as
      context.testCase.getPropertyValue('EXP_PROP')