cancel
Showing results for 
Search instead for 
Did you mean: 

In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

SOLVED
Highlighted
Occasional Contributor

In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

OK - be gentle with me as I'm not techie

 

I'm wanting to create a set of data driven tests for a service where both the request and response wrap all the elements into CDATA

 

So to map the input fields to my data source I've created a request without the CDATA so that I can map every request field to my data source.

 

But of course, the service is expecting to see these fields in CDATA so the requests fail. I know I need to find a way to convert the mapped fields back to CDATA

 

Have tried adding a Event, Requestfilter.filterRequest with the following:

 

//This event handler will affect all requests

if( request.requestContent == null )
   return
log.info "Old request without CDATA : " + request.requestContent
def requestContent = request.requestContent


//requestContent = requestContent.replaceAll( "<!\\[CDATA\\[", "" )
//requestContent = requestContent.replaceAll( "]]>", "" )

 

requestContent = requestContent.replace ( "<Input>" , "<![CDATA[<Input>" )
requestContent = requestContent.replace ( "</Input>" , "</Input>]]>" )

log.info "New request with CDATA : " + request.requestContent
request.requestContent =  requestContent

 

 

Tried testing this event in a manual test step and  the first call fails with Unmarshalling Error: unexpected element (uri:"", local:"Input"). Expected elements are (none)

A second call concatenates the event but actually works ok

A third call concatenates the event and fails with Unmarshalling Error: String ']]>' not allowed in textual content, except as the end marker of CDATA section
 at [row,col {unknown-source}]: [68,20]

 

I know I'm close to getting this working so would appreciate some help !

6 REPLIES
Community Manager

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

Hi Mikegatward,

 

 

 

From my understanding, judging by this error:

unexpected element (uri:"", local:"Input")

the test cannot find the Input element in your request. I suggest that you check its content. Do you see Input there?

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
Occasional Contributor

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

 
Occasional Contributor

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

 
Occasional Contributor

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

 
Occasional Contributor

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

I've added some screenshots

 

first shows the request I edited to remove the CDATA wrapper so I can map input fields to my data source

 

second show the Event I created to try and add the CDATA wrapper back to the request before it sets sent

 

third shows a manual request failing when the event has been enabled

 

fourth shows the same request succeeding when I run again  

 

the input tag is most definitely there !

Occasional Contributor

Re: In a data driven Test Suite, how do I convert the <input> child tags into CDATA ?

Thanks for the reply but I've figured I don't actually need to create this wrapper. I took the CDATA out of the base request so I could map input fields against the datasource. Having done this, I manually added the CDATA wrapper into the base request and was delighted to see the datasource mappings remain in the CDATA text. So job done and it's working a treat

2018 NEWS