How to assert if a particular value exist in the response using Script Assertion
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018
07:01 AM
06-27-2018
07:01 AM
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
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018
07:31 AM
06-27-2018
07:31 AM
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!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018
07:57 AM
06-27-2018
07:57 AM
Looks like we have this topic twice.
@groovyguy you response is right on the money
I just gave high level psuedocode.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018
05:25 AM
07-02-2018
05:25 AM
Thank you very much for this! This worked for me
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2018
05:42 AM
07-02-2018
05:42 AM
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!
