Forum Discussion
aaah - my whole SoapUI project got corrupted - I lost all msiadak's and Rao's good work!
if anyone gets the following warning "WARN:Test Monitor: Trying to unregister a non-existing test model item [model item ID" - in the ReadyAPI! Log - don't ignore it. I lost ALL my tests.
if you get this warning - do the following (sourced from https://community.smartbear.com/t5/SoapUI-Pro/Error-notifying-listener-before-run-ReadyAPI-1-8-0/td-p/126862)
1. On the SoapUI NG tab, double-click a project and check the "Compare" or "History" screen. Do you see the "Test Run History Disabled" message on them (see: http://screencast.com/t/eDWaD300USH)? If so, back up the DB, and then update it. Does this resolve the issue?
lesson to all (and me especially) backup all your stuff
groovyguy - YES - there is only 1 VenueID in any request. BTW - you'll be getting another email later on tonight with the correct details
Cheers to all!
richie
Okay, working with the last script you had modified and posted, here's what I have:
import com.eviware.soapui.support.XmlHolder def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ); // get the response, specifically the //RETURN element that contains DATA tags def response = context.expand( '${TESTTSTEP#Request#declare namespace NS1=\'urn:SyncServicesIntf-ISyncServices\'; //NS1:SyncResponse[1]/return[1]}' ) // remove the CDATA tags response = response.replaceAll( "<!\\[CDATA\\[", "" ) response = response.replaceAll( "]]>", "" ) // Parse the response into XML def holder = groovyUtils.getXmlHolder( response ) log.info((holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"])); log.info(holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]); log.info(holder["count(//Responses/VenueSyncIgnores/VenueSyncIgnore)"]); def successExists = (holder["exists(//Responses/VenueSyncSuccesses/VenueSyncSuccess)"]); def errorCount = (holder["count(//Responses/VenueSyncErrors/VenueSyncError)"]).toInteger(); def ignoreCount = (holder["count(//Responses/VenueSyncIgnores/VenueSyncIgnore)"]).toInteger(); 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 Test Step Name"]; propertiesStep.setPropertyValue("VenueID", syncID); } assert (successExists && errorCount == 0 && ignoreCount ==0);
The new addition will transfer the VenueID from the success statement to a properties step. You can then reference in other steps (JDBC request, etc) with property expansion like ${PropertiestestStepName#PropertyName}
Does that help?
- richie7 years agoCommunity Hero
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
- groovyguy7 years agoChampion Level 1
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 - 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
Related Content
- 20 days agoStoplight
- 4 years agomehdisinger
Recent Discussions
- 18 minutes agodipsthorat
- 5 hours agoisbiat
- 2 days agoarmygrad