How to Trim Json Response and Parse the Data to the next Step in the Test Case
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017
04:09 AM
07-27-2017
04:09 AM
How to Trim Json Response and Parse the Data to the next Step in the Test Case
Json Response in Step 1 = iaa.service.response/v2/policy/4512650
I only want to use the number 4512650 and parse it to the next Step in the Test case
2 REPLIES 2
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017
04:53 AM
07-27-2017
04:53 AM
@noegh_mmi,
Was that the whole response? or just a string and you want to extract that value?
Or was it a resource path you mentioned?
Or you want to access it in the mock service script dispatcher?
Please clarify.
Regards,
Rao.
Was that the whole response? or just a string and you want to extract that value?
Or was it a resource path you mentioned?
Or you want to access it in the mock service script dispatcher?
Please clarify.
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2017
05:02 AM
07-27-2017
05:02 AM
In case if that is just a string and need to extract the value?
def str = 'iaa.service.response/v2/policy/4512650' //Get the id def policyId = str.substring(str.lastIndexOf('/')+1, str.size()) //Save it at test case level custom property for later use context.testCase.setPropertyValue('POLICYID', policyId)
In the next step, use property expansion i.e., ${#TestCase#POLICYID} where every it is needed
Regards,
Rao.
