Can you guys please help me on this. How to compare multiple JSON Elements with DB elements in one script and capture the result in Excel sheet
as
JSON ELEMENTELEMENT DATA BASE ELEMENT VALUE RESULT
123 123 PASS
1234 456 FAIL
I'm able to compare (Json Response Element vs DB Response) only one element at a time with the below script and capturing the results in excel sheet as above for one element. Attached is the sample screen snippet of my test steps and end result excel sheet
I'm creating a property as Result with Blank
context.testCase.setPropertyValue("Result","")
Groovy Script
import groovy.xml.*
import groovy.json.*
def response = context.expand( '${REST Request#Response#$[\'STMT_BK_ADDR_LINE\'][\'STMT_ADDR_MONETARY_ID\']}' )
log.info response
def responseAsXml = context.expand( '${JDBC Request#ResponseAsXml#//Results[1]/ResultSet[1]/Row[1]/STMT_ADDR_MONETARY_ID[1]}' )
log.info responseAsXml
context.testCase.setPropertyValue("DBResponse",responseAsXml)
context.testCase.setPropertyValue("JsonResponse",response)
if(response.equals(responseAsXml))
{
context.testCase.setPropertyValue("Result","pass")
}
else
{
context.testCase.setPropertyValue("Result","fail")
}