Forum Discussion
I merged your two threads together since they are so closely related. For doing the property transfer, you are going to probably need to use a groovy script as well due to having to manually parse the CDATA tag(s).
import com.eviware.soapui.support.XmlHolder def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); // get the response, specifically the //RETURN element that contains DATA tags def response = context.expand( '${TESTTSTEP#Request#declare namespace NS1=\'urn:SyncServicesIntf-ISyncServices\'; //NS1:SyncResponse[1]/return[1]}' ) // remove the CDATA tags response = response.replaceAll( "<!\\[CDATA\\[", "" ) response = response.replaceAll( "]]>", "" ) // Parse the response into XML def holder = groovyUtils.getXmlHolder( response ) // Parse the XML of the cdata for the attribute def successID = (holder["//Responses/SyncSuccesses/SyncSuccess/@SyncID"]); // set the property in a property test step properyTestStepName.setPropertyValue("SyncID", successID);
- richie8 years agoCommunity Hero
nice one to groovyguy
I made some small updates and its working (see below)
import com.eviware.soapui.support.XmlHolder def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); // get the response, specifically the //RETURN element that contains DATA tags. This may need to be adjusted to fit your own project, but you want to collect the //return element def response = context.expand( '${SOAP Request#Response#declare namespace NS1=\'urn:CSMVenueSyncServicesIntf-ICSMVenueSyncServices\'; //NS1:SyncVenueResponse[1]/return[1]}' ) // remove the CDATA tags response = response.replaceAll( "<!\\[CDATA\\[", "" ) response = response.replaceAll( "]]>", "" ) // Parse the response into XML def holder = groovyUtils.getXmlHolder( response ) log.info((holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"])); log.info(holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]); def successExists = (holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"]); def errorCount = (holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]).toInteger(); assert (successExists && errorCount == 0);
I've placed the groovy step immediately after my SOAP Request step and it generates 2 rows in the logging as follows:
So - the above is logging the info fine - returns 2 rows depending on the presence of VenueSyncSuccess & VenueSyncError tags are present
I can see the 'assert (successExists && errorCount == 0);' line - can you confirm what they are actually doing?
FINALLY - I need to create an ASSERTION on the above somehow to indicate during execution whether the VenueSyncSuccess is present or not (to prove the request was successful)
I have both positive and negative tests that will generate either a VenueSyncSuccess tag or a VenueSyncError tag - I need to (based on the purpose of the test) assert whether these are present or not - can you please advise?
I raised a separate query a while back about passing logged info to a PROPERTY test step - would this allow me to assert on the values?
I'm sorry - I avoid groovy just because I dont know where to start (I'm the only tester where I work - so it;s not like I can ask anybody else!)
Many thanks - you're really saving my life here!
richie
Related Content
- 4 years ago
- 3 years ago
- 7 months ago
Recent Discussions
- 4 days ago