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
Have you taken a look at the content assertion documentation:
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.
The Message Content assertion lets you do exactly that:
You can also use the XPath Match assertion with the following config:
exists( //Row[T2="TASK1" and T3="Value1"]/following-sibling::Row[T2="TASK2" and T3="Value1"])
Expected result: true
SmartBear Documentation Team Lead
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️