Ask a Question

Groovy Script to assert multiple values in an XML response received on querying DB from SOAP UI

Sunny2
New Contributor

Groovy Script to assert multiple values in an XML response received on querying DB from SOAP UI

I am trying to retrieve some data from db and based on the response, I have to pass or fail a test case. I have to do this each time I query the db

I am able to make the connection to the db and get the response. However, not quite sure on how to assert the values from the response

Tried to use Script Assertion but not able to figure out as I am completely new at this

 

<Results>
<ResultSet fetchSize="10">
    <Row rowNumber="1">
        <T1>TEXT1</T1>
        <T2>TASK1</T2>
        <T3>Value1</T3>
        <T4>xyz</T4>
      </Row>
       <Row rowNumber="2">
        <T1>TEXT2</T1>
        <T2>TASK2</T2>
        <T3>Value1</T3>
        <T4>ABC</T4>
      </Row>
     </ResultSet>
<Results>

From the above response, on the first step I will have to assert that "TASK1" exists and the "Value1" exists with in the same set followed by the "TASK2" and "Value1"

Please let me know if this is vague so that I can try to modify my query

3 REPLIES 3
Radford
Super Contributor

Have you taken a look at the content assertion documentation:

 

http://readyapi.smartbear.com/structure/assertions/property/content/start

 

Rememeber that when you are looking at the results of your JDBC query in the "Outline" view you can right click on returned data to add assertions easily.

 

If new to Ready API I suggest you take a look at the Point And Click Testing documentation.

 

 

nmrao
Champion Level 3

Looks the same is posted in so, happned to answer there:
http://stackoverflow.com/questions/42661315/assert-multiple-values-in-an-xml-response-received-on-qu...


Regards,
Rao.
HKosova
SmartBear Alumni (Retired)

The Message Content assertion lets you do exactly that:

 

message-content-assertion.png

 

You can also use the XPath Match assertion with the following config:

XPath Expression:

exists( //Row[T2="TASK1" and T3="Value1"]/following-sibling::Row[T2="TASK2" and T3="Value1"])

Expected result: true


Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
cancel
Showing results for 
Search instead for 
Did you mean: