Check Out the Latest News About SmartBear Connect
JOIN OUR WEEKLY CHALLENGE
API_Bloom_banner

API Bloom is a weekly prize-winning challenge in the Ready! API Community. Each week, we assign a task that you need to accomplish to become a winner. See the rules here.

THIS WEEK TASK
Give the biggest number of Solutions on the Ready! API forums
Top 3 contributors will get $50, $35, and $15 gift cards!

WEEK 1-12 WINNERS
@nmrao, @msiadak, @Debz, @richie, @Emil91, @PramodYadav, @jkrier, @sanj, @mbheeke, @Radford, @kmaster, @kbw

Reply
Highlighted
New Contributor
Posts: 3
Registered: ‎08-12-2017

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

[ Edited ]

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.

 

 

 

Community Hero
Posts: 4,598
Registered: ‎05-17-2013

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

Can you show the raw response of the above mentioned step?
Frequent Contributor
Posts: 93
Registered: ‎12-06-2016

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

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

New Contributor
Posts: 3
Registered: ‎08-12-2017

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

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

Community Hero
Posts: 4,598
Registered: ‎05-17-2013

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

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

See below demo
http://ideone.com/ZIficC
New Contributor
Posts: 3
Registered: ‎08-12-2017

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

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

 

Let's Meet in Boston
Join the user conference on Sep 12-13