cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Dynamic tags in response

Highlighted
New Contributor

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. ">

            <b:tag1>Value1</b:tag1>

            <b:tag2>Value2</b:tag2>

         </ TagResult >

      </ TagResponse >

 </s:Body>

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

      <s:Fault>

         <s:Code>

            <s:Value>s:Sender</s:Value>

            <s:Subcode>

               <s:Value>s:READERR</s:Value>

            </s:Subcode>

         </s:Code>

         <s:Reason>

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

         </s:Reason>

         <s:Detail>

            <FaultDetails xmlns="http://www. " xmlns:i="http://www.w3.org/2001/XMLSchema-instance">

               <FaultDetail>

                  <Cause>Serialization Error</Cause>

                  <Code>READERR</Code>

                  <Description>There was an error</Description>

                  <FailingFieldName i:nil="true"/>

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

                  <Source>Framework</Source>

               </FaultDetail>

            </FaultDetails>

         </s:Detail>

      </s:Fault>

   </s:Body>

 

4 REPLIES 4
Highlighted
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

Highlighted

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.



Regards,
Rao.
Highlighted

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

Highlighted

This problem is resolved. I used contains method for conditioning by converting entire response as string. It worked for my case.

Thanks for your help. 🙂

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors