Functional Web Services Testing Made Easy with SoapUI - Part 2
6.Parse the response from the above request using Groovy and assert.
Right click on the Test Case and select the Add Step -> Groovy Script. This will open up an editor. In this editor, we will write the Groovy script that will parse the response and also add a few assertions. Also, assign the latitude and longitude to the context which can be used within the next request.
groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
holder = groovyUtils.getXmlHolder("LatLonListZipCode - Request 1#Response" )
listLatLonOut = holder.getNodeValue( "//listLatLonOut" )
assert listLatLonOut != null
assert listLatLonOut.length() > 0
latlonNode = groovyUtils.getXmlHolder(listLatLonOut)
latlon = latlonNode.getNodeValue("//latLonList")
log.info(latlon)
assert latlon !=null
context["latlon"] = latlon
- Login or register to post comments
- 34314 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
jbaker replied on Wed, 2008/11/19 - 3:20am
Meera Subbarao replied on Wed, 2008/11/19 - 8:05am
esad48 replied on Fri, 2009/01/16 - 6:26am
hi,
one question, is it possible to pass the responce from one test case to another test case. What i'm trying to do is to get a session id and then use that session id to run a load test.
Thx.
Meera Subbarao replied on Fri, 2009/01/16 - 10:58am
in response to: esad48
shanbala replied on Fri, 2009/02/27 - 2:25am
Meera Subbarao replied on Tue, 2009/03/03 - 11:18am
in response to: shanbala
sureshreddy04 replied on Wed, 2009/03/18 - 10:24pm
After seeing into ur article I whould like to know how can i obtain session ID to logout automatically when I login and logout of the webapplicaiton.
mevric75 replied on Tue, 2009/06/16 - 6:47pm
jafar_bt replied on Thu, 2009/08/06 - 4:25am
Hi Meera,
How could I change the project properties, test suite properties or testcase properties values using Groovy script test step. I wasn't able to understand the syntax.
def sessionID = context.expand( '${#Project#SessionID}' )
def testSuiteProperty = context.expand( '${#TestSuite#TestSuiteProperty}' )
def test1 = context.expand('${#TestCase#test}' )
I understood the above lines collect the values of the given properties. Please help me to set the value for SessionID, TestSuiteProperty, test parameters. Thanks in advance.
jafar_bt replied on Fri, 2009/08/07 - 2:29am
in response to: jafar_bt
I have found the info. The format is as follows:
testRunner.testCase.testSuite.project.setPropertyValue("SessionID","2002")
testRunner.testCase.testSuite.setPropertyValue("TestSuiteProperty","testSuiteProperty")
testRunner.testCase.setPropertyValue("test","testcase property")
However, I have another issue. If the assertion is faliled I am unable to continue to execute the further steps of testcase. Please help me regarding this concern...
kkairan replied on Mon, 2009/09/14 - 4:16am
I am trying to get the Node Value but I get it as Null
IST 2009:INFO:null
This is the Script I am running groovyUtils = new com.eviware.soapui.support.GroovyUtils( context ) holder = groovyUtils.getXmlHolder("GetData - Request 1#Response") dwmlByDayOut = holder.getNodeValue( "//GetDataResponse" )
Below are the Request Iam sending and the response I get
${Properties#Addvalue}
This is my response
You entered: 500
sztgeza replied on Fri, 2009/10/09 - 3:13am
Hi all!
For the TestCase setup script to work, i think it needs to add the following lines before file.createNewFile(), Otherwise i experienced an IOException, which was thrown by file.createNewFile(), when the parent directory had not existed before.
...
if(!file.exists())
{
if (file.getParentFile() != null) {
file.getParentFile().mkdirs()
}
file.createNewFile()
...
Nice article, anyway!
sunrise1 replied on Mon, 2009/10/26 - 3:26am
nkunchupu replied on Wed, 2009/11/25 - 7:31am