Forum Discussion
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
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.
- roja15 years agoContributor
Hi HimanshuTayal ,
Sorry for the delay in the response.
I'm not saving excel file into properties test step. I have an excel file which has a test step name in one column, fields(comma seperated) which we are expecting in the response body in one column. Now in my groovy script I want to read the fields against a particular test step and check if those fields are present my response are not.
Related Content
- 5 years ago
- 2 years ago
- 10 years ago
- 2 years ago