Forum Discussion

rprsekhar's avatar
New Contributor
6 years ago

Reading Dynamic tags in response

I am using SOAP UI free version. I am beginner and working on a groovy script to read a excel, replace properties in a request file and run the request in a loop. For reading response, i gave xpahs and writing the data to a text file. This works fine for a pass scenario because of the xpath. For failed scenario, given xpath is not valid and comes with  different tags. So, i am looking to find a way to validate pass or fail or condition the xpath based on a particular tag.

Given xpath for reading data:

def tag1 =  responseXmlHolder["//b:tag1"]

def tag2 =  responseXmlHolder["//b:tag2"]

Sample Pass Response

Sample Failure Response

<s:Body u:Id="_2">

      <TagResponse xmlns="http://www. ">

         <TagResult xmlns:b="http://www. ">



         </ TagResult >

      </ TagResponse >


<s:Body u:Id="_2">









            <s:Text xml:lang="en-GB">Serialization Error</s:Text>



            <FaultDetails xmlns="http://www. " xmlns:i="">


                  <Cause>Serialization Error</Cause>


                  <Description>There was an error</Description>

                  <FailingFieldName i:nil="true"/>

                  <Solution>Please change the value and try again</Solution>








4 Replies

  • rprsekhar's avatar
    New Contributor

    I need some help with adding a condition to read a value and then identify the results. Like if failed then i can read a set of properties using xpath. If passed then i can read a set of properties using different xpaths. Thanks in advance

    • nmrao's avatar
      Champion Level 3

      Things is the targeted test result is known to you before even testing.
      If the test is for positive case, that should pass the respective assertion(s).
      If the test is negative case, then also the test should pass with respective assertion(s).

      Any case, assertions should be passed.

      So, design the test cases accordingly.

      • rprsekhar's avatar
        New Contributor

        Thanks Mr. nmrao for the response. nmrao 

        I want to put these conditions in same script. 

        The pass and failure depends on the input i supply for same request. So, i am trying to read both conditions in same script. Based on the xpaths(which depends on the response), it should read the required xpath and ignore the other part. I have to read the xpaths. If xpath1 exists then i have to read the response 1 else if xpath 2 exists i have to read the response2.

        Thanks in advance