Forum Discussion
roja1
6 years agoContributor
Hi HimanshuTayal ,
Thank you for your reply. What I'm trying to achieve is I will reading the fields from an excel file and check if they are present in the response or not.
For eg:
I will be reading cityCode and cityName from a column in excel file.
My response is as below:
[{
"cityCode": "2345",
"cityName": "abc"
}]
I need to check if both cityCode and cityName are present in the response or not
So the comparison should be dynamic and automatic but not manual
HimanshuTayal
6 years agoCommunity Hero
roja1 :
I am assuming that you have saved your Excel file values into Properties step from where you can fetch and validate response values, you can use below groovy code to validate the values with the excel sheet values.
def cityCode = ${Proeprties#cityCode}
def cityName = ${Proeprties#cityName}
def jsonSlurper = new JsonSlurper().parseText(response)
assert cityCode == jsonSlurper.cityCode : "City Code value is different"
assert cityName == jsonSlurper.cityName : "City Name value is different"
Let me know in case you need more help.