Ask a Question

Event to remove CDATA from response

MikeGatward
Occasional Contributor

Event to remove CDATA from response

So - the service I am testing returns its relevant data in a CDATA wrapper. I created an event to remove the CDATA wrapper so that I can assert against xml fields.

 

It works fine but when my tests are in a Datasource Loop, the event only runs within the loop if I send a request first.

 

It's annoying that I've a mass of regression tests to run but I have so send the request once before I can kick off the loop

 

Any ideas ?

 

Event is a SubmitListener.afterSubmit abd contains:

 

if( submit.response == null )
   return
def responseContent = submit.response.responseContent
responseContent = responseContent.replaceAll( "<!\\[CDATA\\[", "")
responseContent = responseContent.replaceAll( "]]>", "" )
responseContent = responseContent.replace( '<?xml version="1.0" encoding="UTF-8"?>',"" )


log.info( responseContent )
submit.response.responseContent =  responseContent

 

 

2 REPLIES 2
Nastya_Khovrina
SmartBear Alumni (Retired)

Hi Mike, 

 

Can you please describe your issue in more detail? Provide us with a screenshot of your test case configuration when it works and when it doesn't work.

If I understand you correctly, the event only works if you send a request as a first step in the loop. If it is the issue, then I cannot reproduce it, please see my sample video: https://www.screencast.com/t/s1j83v4Px4

 


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
PaulMS
Super Contributor

https://www.soapui.org/docs/functional-testing/working-with-cdata.html

 

This article suggests adding RequestFilter.afterRequest handler

cancel
Showing results for 
Search instead for 
Did you mean: