Forum Discussion
My environment's db is down at moment so I can try it properly - I'm sure it works - all the groovy you've given so far always does!
Anyway - I have 2 questions.
In regards to editing the testcase to support the script - I just need to create a Properties step (edit the groovy to point to the Properties step) AFTER the groovystep and within the Properties step I create a property entitled 'VenueID' is that right? or does the groovystep actually create the 'VenueID' property in the step as well as populate the 'VenueID' property with the value?
Second question. Quite often when you've given me some groovy before and today and yesterday - I kept getting an error response 'org.apache.xmlbeans.XmlException: error: Unexpected element: CDATA
error at line:13'
Now I've had a similar error before (when I've just ran the groovy to check it works) and I've either just run the test case or made a couple of edits and all of a sudden the groovystep doesnt generate the error response anymore. It seems like I need to initialise (for want of a better word) the groovy - sometimes just editing it will get rid of the error - sometimes running the whole test case (within the groovystep embedded resolves the problem). Is there something I should be doing that I'm not? I had it a couple of years ago when I'd come into work, try and execute a groovystep and I'd get an error - later in the day I wouldnt. I know this sounds a little flaky - and for the most part - software isnt. I'm just wondering if there's something I can do to minimise this?????
Many thanks again,
richie
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.
- richie7 years agoCommunity Hero
Ok - ticket was raised with SmartBear but they couldn't replicate the problem.
HOWEVER - I had to install JDK v2 to support the jdbc driver .jar file to query the stupid MIMER DB I needed to connect to.
I got around the problem by rollin the JDK forward back up to JDK v8, despite the support page saying the driver wouldnt work with later versions of Java - it did!
So all good!
Cheers!
- richie7 years agoCommunity Hero
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
- groovyguy7 years agoChampion Level 1
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.
- richie7 years agoCommunity Hero
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!
- groovyguy7 years agoChampion Level 1
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. :(
- groovyguy7 years agoChampion Level 1
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.
- richie7 years agoCommunity Hero
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
- groovyguy7 years agoChampion Level 1
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.
- richie7 years agoCommunity Hero
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
- richie7 years agoCommunity Hero
ignore - I hit send twice
Related Content
- 4 years agomehdisinger
- 2 months agoStoplight
- 3 years agoprekar