We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
I dont know if this will help or not.
I was playing around with this a couple of week's ago - not specifically for work - I just hadn't used the groovy/xml/json datasources before so started to play around with the functionality.
I had a LOT of trouble with json datasource, perhaps I was doing something wrong (I also find xpath easier to read than jsonpath) - but I found setting it up was a lot easier if I used an XML datasource instead.
Despite the fact that the response of the request that I was using to populate my datasource was actually .json - I added the XML datasource in and specified the 'source property' dropdown on the XML datasource as 'ResponseAsXML'.
I was then able to build up a datasource of attributes successfully sourced from the response without too much trouble.
Just a suggestion,
Cheers,
richie
Thank you Rao. I appreciate the feedback.
Your response pointed me in the direction of using a Groovy Script step to meet my goal.
Here' the script I ended up using...
// Get the Json response from the Catalog Service GET.
def jsonResponse = context.expand( '${GET Catalog Services#Response}' )
def parsedJson = new groovy.json.JsonSlurper().parseText(jsonResponse)
// Loop thru each service that's defined in the response...
def iNumServices = 0
def checkStatusStep = "CHECK Service Status"
parsedJson.each { serviceNode ->
if (serviceNode.value.Service != 'consul') {
iNumServices = iNumServices + 1
//Store the next service name in testcase property 'ServiceName'.
//The <CHECK Service Status> step will retrieve the service name from this property.
testRunner.testCase.setPropertyValue("ServiceName", serviceNode.value.Service)
//Perform a GET on this web service and check the response status.
//If the response status code is NOT 200, an assertion will be logged.
log.info "Checking ALIVE status for service ->" + serviceNode.value.Service
testRunner.runTestStepByName(checkStatusStep )
}
}
assert iNumServices >= 1 : "No services returned by Resource Catalog!"
testRunner.gotoStepByName("The End")