cancel
Showing results for 
Search instead for 
Did you mean: 

Can json attribute values be compared with values in properties for assertions

SOLVED
Highlighted
Frequent Visitor

Can json attribute values be compared with values in properties for assertions

Is there a possibility to add assertion in a way that certain value to an attribute in the json should be equal to value in the properties (where value in the properties is dynamically populated when uploading data from the excel, so that is not a fixed value)

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Hero

Re: Can json attribute values be compared with values in properties for assertions

Definitely possible.

If using properties, why am excel? Can't you use . properties file?



Regards,
Rao.

View solution in original post

2 REPLIES 2
Highlighted
Community Leader

Re: Can json attribute values be compared with values in properties for assertions

@SahithiAnirudh :

 

Yes this is absolutely possible by adding script assertion and parsing your response and asserting desired values.

Refer below script for help:

 

import groovy.json.JsonSlurper

//getting data from response
def response = messageExchange.responseContent
//parsing data with JsonSlurper
def jsonSlurper = new JsonSlurper().parseText(response)
//Getting data from properties
def tenure = context.expand('${Properties#tenure}')
//getting data from response's particular node
tenureResponse =  jsonSlurper.tenure

//asserting both the data
assert (tenure == tenureResponse) : "Value didn't match in properties : "+tenure+" in response : "+tenureResponse

 

Hope it will help you 🙂


Click "Accept as Solution" if my answer has helped, and remember to give "kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
Highlighted
Community Hero

Re: Can json attribute values be compared with values in properties for assertions

Definitely possible.

If using properties, why am excel? Can't you use . properties file?



Regards,
Rao.

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors