Thanks HimanshuTayal for your reply! Sorry this is all pretty new to me.
I am still unsure how to set the ID field as a property. To be clear, I know the groovy command for setting the property, I am just not sure how to tell the command that I want the property value to equal the ID field that has a sibling 'node' that is equal to TestB. What gives me trouble is the indexing. Once I find the desired value in the node field how do I take that index and apply it to the ID field so that I get the desired ID? Am I going down the wrong path with indexing? Is there a way to do it via wildcards? I'm not sure if I should be using JsonSlurper to parse the Json then do my comparison in the groovy script.
This is the response for the test case named: "GET/Nodes".
[
{
"id": 9661,
"node": "TestA"
},
{
"id": 9662,
"node": "TestB"
}
]
For instance how would I write it so that it would check all id fields and not just the one specified with an index?
Is this correct?
def x = 0
def response = context.expand( '${GET/Nodes#Response#$[x][\'node\']}' )
def nodeId = context.expand( '${GET/Nodes#Response#$[x][\'id\']}' )
if (response != 'TestB') {
x++;
}
else{
testRunner.testCase.testSuite.setPropertyValue('nodeId', nodeId)
}