cancel
Showing results for 
Search instead for 
Did you mean: 

Grab value within XML fragment within a single XML element (CDATA element query)?

Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

 

The properties step should be all you need to create. The groovy script part with "propertiesStep.setPropertyValue("VenueID", syncID);" both creates the property and populates the value from the parsed response. So all you have to do is create the property test step, and change "def propertiesStep = context.testCase.testSteps["Properties Test Step Name"];" with the appropriate name. This script does assume all tests (including the following one that uses the property step's VenueID) are all in the same Test Case.

 

Second question, I can only imagine that maybe copying the script from the website causes it to pick up an extra character that makes ReadyAPI freak out. Unfortunately I have not seen that particular problem. If you remember, next time you get that error, screenshot the part of the script in question that it is complaining about? I might be able to help then.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

Ok - here's a screenshot

 

 

currently the groovystep isn't executing in the test case (cos of that weird failure).

 

I've attached an image of the failure.

 

I should highlight that I copied the content from the forum to a notepad file and then copied that into the groovystep.

 

I'm gonna type the whole thing out rather than use copy/paste and see if that makes a difference

 

back in 20mins  🙂

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

Try this.

 

def response = context.expand( '${TESTTSTEP#ResponseAsXml#declare namespace NS1=\'urn:SyncServicesIntf-ISyncServices\'; //NS1:SyncResponse[1]/return[1]}' )

 

Found it here: https://community.smartbear.com/t5/SoapUI-Open-Source/Groovy-Unexpected-element-CDATA/td-p/36454




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

I thought about typing the whole thing out again and reasoned that I'm likely to make small mistakes that I'd find difficult to spot and on top of that, char encoding issues normally surround special characters - so I went with the middle option and replaced all the special chars in the script.

 

not that that means I didn't make a mistake - my laptop screen's not huge and I replaced 2 curly braces with brackets instead - so the whole thing fell over when I tried to run it again!

 

Finally I replaced the curly braces and overwrote 'Request' with 'ResponseAsXML' within the string you identified, but still no luck

 

I even used the old technical support standby of bouncing my machine and it still didn't work.

 

And now - even the original script I had working yesterday generates the same error response.  

 

I did have this error when I initially copied the original groovy yesterday - but I'd altered the paths in the original post slightly (removed the word Venue from everywhere) trying to be security conscious and once I'd added the word 'Venue' to all the paths - the error response no longer manifested - I'll try editing the thing again and see if that miraculously does what logic and common sense cant achieve!

 

This bites!

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

The only thing I can think of to try is to try the script in a different project entirely? Maybe there's something wrong with the project itself. 😞 




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

Mind posting your script again? I can try to run it on my side and see what happens. I can mock up a response based on the samples you provided and see if I can manage to help troubleshoot.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

you won't believe this -but its true.

 

I edited the file again -essentially overwriting all the paths as they currently appear - so literally - I replaced 'SyncVenue' with 'SyncVenue'.

 

I commented out the last part (the most recent changes msiadak had made, so I was going to the script msiadak had provided me with yesterday).

 

Issue no longer manifests!

 

I uncommented the additional lines (here they are commented out)

 

//def porps = context.testCase.testSteps["porps"];

//porps.setPropertyValue("Test", errorCount.toString());

// If success exists, that means there's a VenueID to use
// Find the venue id via Xpath, store to properties step
//if (successExists)
//{
//	def syncID = (holder["//Responses/VenueSyncSuccesses/VenueSyncSuccess/@VenueID"])
  //    def propertiesStep = context.testCase.testSteps["Properties"];
	//propertiesStep.setPropertyValue("VenueID", syncID);
//}

Once I'd uncommented out the lines - the error warning occurred again.

 

I replaced the commented section - I typed out the commented section line by line (leaving the commented lines in so I could copy them) - ran the debug

 

 

No error response!

 

this is so annoying - I still cant see any problems - I'm not a groovy coder so I've literally copied out the lines verbatim and it now works!

 

Many thanks to msiadak for putting in all the extra effort spoon feeding me to get me sorted!

 

richie

 

richie

 

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

Glad you got it worked. My guess is that pasting the code here can inject a sort of newline character that ReadyAPI can't handle. Crazy, but it does not surprise me.




---

Click the Accept as Solution button if my answer has helped, and remember to give kudos where appropriate too!
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

sorry - it took me that long to post my response cos i had a latte in one hand - i didn't know you'd responded.

 

Just for your info - I have actually got the groovy in 2 separate projects - I've got the script working in one, and I'm still getting the error in the other and I've overwritten the one that isn't working with the script that is working and I'm still getting the failure with the version I've overwritten.

 

I suspect its copy and pasting groovy content - you no doubt grab code snippets but essentially type out what you need from scratch - I've been using soapui for the last 4 years on and off and every time I've tried resorting to a groovy step - I've copy and pasted and I've generated this 'org.apache.xmlbeansXmlException' error response.

 

Cheers fella - really, really appreciate the help you've given me,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Re: Grab value within XML fragment within a single XML element (CDATA element query)?

ignore - I hit send twice

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors