Forum Discussion
The Xpath expression returns more than 1 match, but the expected result shows only the first match. This seems to be a limitation of property expansion in SoapUI.
You could add a separate assertion for each name and just increment the indexes.
JSONPath Expression = $..data.name[0]
Expected Result = ${JDBC Request#ResponseAsXml#//ResultSet/Row[1]/GROUPNAME}
Or insert a Groovy script test step to transfer the full list as a string to a property.
import com.eviware.soapui.support.XmlHolder def holder = new XmlHolder( context.expand('${JDBC Request#ResponseAsXml}') ) def nodelist = holder["//ResultSet/Row/GROUPNAME"] def asString = nodelist.join(", ") log.info asString testRunner.testCase.setPropertyValue( "MyProp", "[" + asString + "]" )
- nkpalli8 years agoContributor
Thank you Paul that was helpful ! Can you elaborate on what this statement does in your script assertion as commenting out this statement in assertion script gives me the same value as uncommenting this statement .. so trying to understand what it does
//testRunner.testCase.setPropertyValue( "MyProp", "[" + asString + "]" )
- PaulMS8 years agoSuper Contributor
That line was to set a property value at the test case level with the list of names (enclosed in brackets so it would match a JSONpath expression).
I was using a Groovy script test step, but in a script assertion it would be slightly different because messageExchange is invoked
messageExchange.modelItem.testStep.testCase.setPropertyValue( "MyProp", "[" + asString + "]" )
I didn't mention that the next step for the JsonPath Match assertion would be like
JSONPath Expression = $..data.name
Expected Result = ${#TestCase#MyProp}
Related Content
- 9 years ago
- 8 years ago
- 5 years ago
Recent Discussions
- 7 days ago
- 12 days ago