Coding / Programming Videos

Post your favorite coding videos and share them with others!

SoapUI Beginner Tutorial 17 – How to create Script Assertions

Download Video link >

SoapUI Beginner Tutorial 17 – How to create Script Assertions

Today we will learn:

1. What is Script Assertion
2. How to add Script Assertion
3. Different assertion scripts for xml and json messages
4. Tips and Tricks

Script assertion works on the last reponse received in soapui
works with messageExchange object
(messageExchange object stores all the details of the last request and response)

Script Assertion samples

//check response time
assert messageExchange.timeTaken 4000

//check for Endpoint messageExchange.getEndpoint()

//check for TimeTaken messageExchange.getTimeTaken()

//check for header (messageExchange.responseHeaders[“Content-Length”])
assert messageExchange.responseHeaders[“Content-Length”] != null

//check attachments
assert messageExchange.responseAttachments.length == 0 (messageExchange.responseAttachments.length)

//validate response nodes
def groovyUtils = new context )
def requsetHolder = groovyUtils.getXmlHolder( messageExchange.requestContent )
def responseHolder = groovyUtils.getXmlHolder( messageExchange.responseContent )
def refNum = responseHolder.getNodeValue(“//m:CountryCurrencyResult/m:sName”)
assert responseHolder.getNodeValue(“//m:CountryCurrencyResult/m:sName”) == “Rupees”

//to get response
def resp = messageExchange.responseContentAsXml.toString()

For JSON response

//get json response
import groovy.json.JsonSlurper
def responseMessage = messageExchange.response.responseContent
def json = new JsonSlurper().parseText(responseMessage)

//assert node values
assert != null
assert == “[Taiwan]”

testStepName = get the Test Step Name testStepName
xmlHold = messageExchange.responseContentAsXml.toString() //to store the response as Xml string


#SoapUIScriptAssertions #SoapUIBeginnerTutorials #SoapUITraining #SoapUIBasics #SoapUIAPITesting #ApiTestingWithSoapUI #LearnSoapUI #SoapUIAssertions #SoapUIProject #SoapUITutorials






If you like videos on the channel Automation Step by Step, hit the like button and share with others.

Click the SUBSCRIBE button and hit the bell icon to keep getting new videos.

________ ONLINE COURSES TO LEARN ________

Visit –




View Comments source >

Transcript view all >

00:00 hello and welcome to this session on so

00:03 py beginner tutorial and today we are

00:06 going to learn about script assertions

00:08 in so py and we will see what is a

00:11 script assertion how do we add script

Leave a Reply

Please Login to comment
Notify of
Translate »