How to add properties :
1) Project --> Doubleclick on Project --> Properties bottom .
2) TestSuite--> Doubleclick on TestSuite--> Properties bottom .
3) Testcase--> Doubleclick on Testcase--> Properties bottom .
Onemore way to add properties to testcase -->AddStep --> Property .(Properties add # not required .${CountryCode#Val})
========== syntax pass property values to testcase =========
${#Project#CountryName1}
${#TestSuite#Name}
${#TestCase#CName}
Static : <web:sCountryISOCode>IN</web:sCountryISOCode>
Dynamic : <web:sCountryISOCode>${#TestCase#CName}</web:sCountryISOCode>
=============
Logs :
====
1)Project ---TestSuite --- TestSuite logs
2) TestcaseLevel---Doubleclick Testcase u can find.
Total soap ui logs we can find where soapui is installed --bin --> soapui.logs and soapui.errorlogs.
=============
Get and Set :
===========
we can get and set properties by Groovy scripty .
Diff between add and set property:
=================================
Add property add only Property not allow to asign any value.
Set Property we can add both .
============= Property Transfer ============
Note : if we want to pass 1 response out as a input to use Property Transfer.
1) Add a TestCase to Project name it as Property Transfer demo
2) Go to Soap resest of--CountryIScode -->clone Testcase --> Target Testcase as Property Transfer demo.
3) Go to Soap resest of--CapitalCity -->clone Testcase --> Target Testcase as Property Transfer demo.
4) Right Click on Testcase --> AddStep ..>Property Transfer.
5)Click Add button in Property Transfer.
ref : https://www.youtube.com/watch?v=GSAt7YOvjbY&list=PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF&index=7
=====================
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
============================================== Start Assertions Xpath Match ===========================================
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:iId
1488
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:sName
Aaron Cresswell
Count sNametags presence:
count(//m:sName)
2328
Tag presence:
//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName/m:sName
true
Check sName match:
matches(//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:sName,"Aaron Cresswell")
true
Check Names should have only alphabets:
matches(//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:sName,'[A-Za-z]*')
true
Check ID's should have only digits:
matches(//m:AllPlayerNamesResponse/m:AllPlayerNamesResult/m:tPlayerName[1]/m:iId,'\d')
true