[Resolved] assertion against multiple expected values
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2014
04:26 PM
01-16-2014
04:26 PM
[Resolved] assertion against multiple expected values
I am using soapUI Pro 4.6.4
I have a need were I need to make sure say a "State" field in xml or Json response should have the value of CA or AZ or OR or MA. This is for a REST service.
How do i do it ?
Someone asked similar question, but I believe the reply does not solve the need.
viewtopic.php?f=14&t=21121&p=47544&hilit=validate+multiple+value&sid=7994fae8c6058f407d902bbdd59a4f0...
thanks
Jignesh
I have a need were I need to make sure say a "State" field in xml or Json response should have the value of CA or AZ or OR or MA. This is for a REST service.
How do i do it ?
Someone asked similar question, but I believe the reply does not solve the need.
viewtopic.php?f=14&t=21121&p=47544&hilit=validate+multiple+value&sid=7994fae8c6058f407d902bbdd59a4f0...
thanks
Jignesh
6 REPLIES 6
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2014
07:18 PM
01-16-2014
07:18 PM
As an XPath assertion
As a Script assertion
exists(//*:State[text()='CA'] | //*:State[text()='AZ'] | //*:State[text()='OR'] | //*:State[text()='MA'])
As a Script assertion
def state = context.expand('${' + context.currentStep.name + '#ResponseAsXml#//*:State}')
assert ['CA', 'AZ', 'OR', 'MA'].contains(state)
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2014
07:36 PM
01-16-2014
07:36 PM
thanks a lot SiKing
How would the "Expected Result" in Xpath assertion look like for the following "Xpath Expression"
//ns1:Response[1]/ns1:address[1]/ns1:state[1]
How would the "Expected Result" in Xpath assertion look like for the following "Xpath Expression"
//ns1:Response[1]/ns1:address[1]/ns1:state[1]
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014
07:50 AM
01-17-2014
07:50 AM
this script assertion seem to be working.
utils = new com.eviware.soapui.support.GroovyUtils( context )
holder = utils.getXmlHolder("myRestStep#ResponseAsXml" )
StateField = holder.getNodeValue( "//*[local-name()='state']" )
assert StateKey != null
assert ['CA', 'AZ', 'IL', 'MA'].contains(StateField)
thanks again Siking
utils = new com.eviware.soapui.support.GroovyUtils( context )
holder = utils.getXmlHolder("myRestStep#ResponseAsXml" )
StateField = holder.getNodeValue( "//*[local-name()='state']" )
assert StateKey != null
assert ['CA', 'AZ', 'IL', 'MA'].contains(StateField)
thanks again Siking
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014
07:55 AM
01-17-2014
07:55 AM
Clear Capital* Support wrote: How would the "Expected Result" in Xpath assertion look like for the following "Xpath Expression"
//ns1:Response[1]/ns1:address[1]/ns1:state[1]
Is this a new question, or is this still related to the discussion here? I don't know, probably some kind of string?
Clear Capital* Support wrote: this script assertion seem to be working.
More than one way to skin a cat.

- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2014
10:03 AM
01-17-2014
10:03 AM
That was the question before I put together what I needed with the help of your first response. I am good now . Thanks again.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2017
10:51 AM
01-24-2017
10:51 AM
Hello, newbie to soapui here...
The answers provided seem to be for response content that is XML only not JSON, is this correct?
How would assert for contains multiple values on a json response that is something like this:
{
"result": true,
"content": [
"abc",
"def",
"ijk",
[... <more content>...]
]
}
Thanks
