cancel
Showing results for 
Search instead for 
Did you mean: 

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
msiadak
Community Hero

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

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

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

Looks like we have this topic twice.

@msiadak you response is right on the money

I just gave high level psuedocode.

 

zareen
New Contributor

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

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

 

msiadak
Community Hero

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

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!
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors