Playback starts YouTube’s embedded player (privacy-enhanced mode).
SoapUI Beginner Tutorial 17 - How to create Script Assertions
ChannelAutomation Step by Step - Raghav PalDescription from the creator
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
log.info messageExchange.getEndpoint()
//check for TimeTaken
log.info messageExchange.getTimeTaken()
//check for header
log.info (messageExchange.responseHeaders["Content-Length"])
assert messageExchange.responseHeaders["Content-Length"] != null
//check attachments
assert messageExchange.responseAttachments.length == 0
log.info (messageExchange.responseAttachments.length)
//validate response nodes
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( 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
log.info json.name
assert json.capital.toString() != null
assert json.name.toString() == "[Taiwan]"
testStepName = messageExchange.modelItem.testStep.name//to get the Test Step Name
log.info testStepName
xmlHold = messageExchange.responseContentAsXml.toString() //to store the response as Xml string
__________________________________________________________
#SoapUIScriptAssertions #SoapUIBeginnerTutorials #SoapUITraining #SoapUIBasics #SoapUIAPITesting #ApiTestingWithSoapUI #LearnSoapUI #SoapUIAssertions #SoapUIProject #SoapUITutorials
SOAPUI PLAYLIST
youtube.com/playlist?list=PLhW3qG5bs-L-Bt9T_bny…
YOUTUBE PLAYLIST
youtube.com/channel/UCTt7pyY-o0eltq14glaG5dg/pl…
YOUTUBE
youtube.com/automationstepbystep
FACEBOOK
facebook.com/automationstepbystep
TWITTER
twitter.com/automationsbs
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 - automationstepbystep.com/
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
log.info messageExchange.getEndpoint()
//check for TimeTaken
log.info messageExchange.getTimeTaken()
//check for header
log.info (messageExchange.responseHeaders["Content-Length"])
assert messageExchange.responseHeaders["Content-Length"] != null
//check attachments
assert messageExchange.responseAttachments.length == 0
log.info (messageExchange.responseAttachments.length)
//validate response nodes
def groovyUtils = new com.eviware.soapui.support.GroovyUtils( 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
log.info json.name
assert json.capital.toString() != null
assert json.name.toString() == "[Taiwan]"
testStepName = messageExchange.modelItem.testStep.name//to get the Test Step Name
log.info testStepName
xmlHold = messageExchange.responseContentAsXml.toString() //to store the response as Xml string
__________________________________________________________
#SoapUIScriptAssertions #SoapUIBeginnerTutorials #SoapUITraining #SoapUIBasics #SoapUIAPITesting #ApiTestingWithSoapUI #LearnSoapUI #SoapUIAssertions #SoapUIProject #SoapUITutorials
SOAPUI PLAYLIST
youtube.com/playlist?list=PLhW3qG5bs-L-Bt9T_bny…
YOUTUBE PLAYLIST
youtube.com/channel/UCTt7pyY-o0eltq14glaG5dg/pl…
YOUTUBE
youtube.com/automationstepbystep
facebook.com/automationstepbystep
twitter.com/automationsbs
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 - automationstepbystep.com/
About this tutorial
Automation Step by Step - Raghav Pal published this 17:41 video tutorial on November 13, 2018. It has been watched 32,655 times on YouTube.
- Category
- Education
- Duration
- 17:41
- Published
- November 13, 2018
- Views
- 32,655
- Likes
- 205
Tags
Share
This tutorial in other languages
- FRSoapUI Débutant Tutoriel 17 - Comment créer Script Assertions
- ESSoapUI Principiante Tutorial 17 - Cómo crear secuencias de comandos Las afirmaciones
- PTSoapUI Beginner Tutorial 17 - Como criar Script Afirmações
- ITSoapUI Beginner Tutorial 17 - Come creare script asserzioni
- DESoapUI Anfänger Tutorial 17 - Wie Script Assertions erstellen
- NLSoapUI Beginner Tutorial 17 - Hoe Script Beweringen creëren
- RUSoapUI начинающих Учебник 17 - Как создать скрипт Assertions
- PLSoapUI Początkujący Tutorial 17 - Jak stworzyć skrypt twierdzenia
- JASOAPUI初心者チュートリアル17 - スクリプトアサーションを作成する方法
- ARSoapUI المبتدئين دروس 17 - كيفية إنشاء سيناريو التأكيدات
- HISoapUI शुरुआती ट्यूटोरियल 17 - स्क्रिप्ट दावे कैसे बनाएं
- IDSoapUI Pemula Tutorial 17 - Cara membuat Script Penegasan