Ask a Question

How to assert if a particular value exist in the response using Script Assertion

zareen
New Contributor

How to assert if a particular value exist in the response using Script Assertion

I need to traverse through the list and reach an element based on required value. Before getting inside the loop to traverse, i want to make sure if that value exists in the response . How can i achieve this using Assert statement?

4 REPLIES 4
groovyguy
Champion Level 0

Here's how I would do this:

 

import com.eviware.soapui.support.XmlHolder

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context );

// Fail if the response does not have the value
assert (messageExchange.responseContentAsXml.contains("Value to be checked"));




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
sanj
Super Contributor

Looks like we have this topic twice.

@groovyguy you response is right on the money

I just gave high level psuedocode.

 

zareen
New Contributor

Thank you very much for this! This worked for me Man Happy

 

groovyguy
Champion Level 0

Glad it worked! Don't forget to "Accept as a solution" so future forum visitors can easily see!




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
cancel
Showing results for 
Search instead for 
Did you mean: