Ask a Question

Unexpected Element: CDATA when i m tryinng to run script using test runner

SOLVED
nanikausla
Occasional Contributor

Unexpected Element: CDATA when i m tryinng to run script using test runner

Hi All,

 

I tried to run my groovy script using Test runner, But i m getting the Unexpected element:CDATA.

 

Below is my sample code i have used

 

def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def response1 = groovyUtils.getXmlHolder("Teststepname#Response")
//log.info response1

def groovyUtils1 = new com.eviware.soapui.support.GroovyUtils( context )
def response2 = groovyUtils1.expand('${Teststepname#Response}')
//log.info response2

 

Using response1 i m trying to parse my XML and getting the count of nodes & and their values using Getnodevalues.

 

Later to access the child nodes, I m using the below script

 

def str = response2
def xml = new XmlSlurper(false,true).parseText(str)
def addresslist=new String[serviceaddresscount]

 

When i do  run the script manually, I m able to get the desired response. But when i m trying to run through testrunner.bat., I m getting this error.

 

I tried to debug it, this is giving me as null

log.info(context.getProperty("response2")

 

Tried changing to below, after verifying the comments for the same issues, posted by different erros. But still i m facing same exception

 

def groovyUtils2 = new com.eviware.soapui.support.GroovyUtils(context)
def response3 = groovyUtils2.getXmlHolder("InquireEnterpriseOrderList#ResponseAsXml")
log.info response 3

 

Error getting as "UnexpcetedElement: CDATA"

 

Kindly help me out.

 

 

 

9 REPLIES 9
nmrao
Champion Level 3

Can you show the raw response of the above mentioned step?


Regards,
Rao.
PaulMS
Super Contributor

I'm not sure why testrunner.bat would show a different result. Did you save and close the project before launching TestRunner?

nanikausla
Occasional Contributor

Sorry for delay reply.. This is the raw response, in the above response, couple of elements were in CDM.

nmrao
Champion Level 3

Tried parsing the attached file and able to process and extract values.

See below demo
http://ideone.com/ZIficC


Regards,
Rao.
nanikausla
Occasional Contributor

Thanks you so much for your inputs. Will try once and let you know.....

 

nanikausla
Occasional Contributor

thanks nmrao, The solution worked.

 

Also, can you please help me how to update/set the new value for a particular tag(single instance tag), which is read from the file.

 

I tried to use replaceNode but did not work.

 

Once i replace the value with the new value, i want to trigger that API and check the response back again. 

 

Any solution for this appreciated.

nmrao
Champion Level 3

Suggest you to create a new top along with details.


Regards,
Rao.
nanikausla
Occasional Contributor

I have used loop and identified the tag name which needs to be replaced. But how to pass that new value to the request and trigger it. I got struck there.




 

nmrao
Champion Level 3

It is difficult to image. It would be good if you can explain with an example data or with screen shot etc


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: