Forum Discussion
1 Reply
- Pritish_PandaContributor
1-Run your rest step once with positive data
2-Add a groovy script in your test case .
3-Right click and select Get Data.
3-Go to your rest case and select the test step
4- Add harResponse .
5- In harResponse, there will be #status# which return a code . It returns 2 different code,one for positive & one for negative (please check once with your data)
6-Select #status# from harResponse . (This will give you idea whether your test step is passed or failed )
Example
def harResponse = context.expand( '${#[TestSuite#TestCase#RestStep]#HarResponse#$[\'headers\'][0][\'value\']}' )
let suppose expected #status#="HTTP/1.1 201"
Solution_1
After that use this code
if(harResponse_StatusCode.equals(harResponse))
{
//get your data from rest step in the same way as above mention(this time select response in place of harResponse)
Example
def getResponseInfo = context.expand( '${#[TestSuite#TestCase#RestStep]#Response#$[\'responseInfo\']}' )
def globalProperties=com.eviware.soapui.SoapUI.globalProperties
globalProperties.setPropertyValue("SetGlobalpropertyName", "$getResponseInfo")
}
Solution_2
try{
//get your data from rest step in the same way as above mention(this time select response in place of harResponse)
Example
def getResponseInfo = context.expand( '${#[TestSuite#TestCase#RestStep]#Response#$[\'responseInfo\']}' )
def globalProperties=com.eviware.soapui.SoapUI.globalProperties
globalProperties.setPropertyValue("SetGlobalpropertyName", "$getResponseInfo")
}
catch(Exception)
{
log.error " rest step is failed "
}
Hope this will help you,let me know if you face any problem.