How do I verify that multiple values are all the same for an unknown amount of values?
I have some XML and want to verify the name column all contain the same name. There may be 1 row or there may be 20 rows. There is no way to know how many there will be.
How do I verify the name of all of them is "Joe"?
Right now the Xpath is returning: [[ Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe , Joe ]]
But I can't just put "Joe" in the expected result because it's expecting more than one sometimes. So how do I make it dynamic so that it checks for "Joe" for any number of values?
Absolutely. Here's the way I did it in a groovy script assertion. First I retrieved the XML into an array and then looped through the array to verify each one. And that seems to be the problem with a regular Xpath assertion which is that I couldn't figure out how to loop through an unknown amount of values.
import com.eviware.soapui.support.XmlHolder
def holder = new XmlHolder(messageExchange.responseContentAsXml)
def resultsArray = holder.getNodeValues("<XPATH GOES HERE>")
//Loop array and verify what you need
resultsArray .each{
assert "${it}" == "<insert assertion string>"
}