I'm trying to parse a bunch of ids out of an xml and loop over them to run some other test steps.
The xml basically boils down to this (removing all the extra):
<tr>
<td>
<a>11111</a>
</td>
</tr>
<tr>
<td>
<a>11112</a>
</td>
</tr>
<tr>
<td>
<a>11112</a>
</td>
</tr>
My code is the below.
// Defines the row to pass things in, will change based on iteration (hence the 'currentRow')
def row = testRunner.testCase.testSteps["DataSource"].currentRow
// Pulling in reponse
def responseAsXml = ***REST request xml response***
def xmlParser = new XmlSlurper().parseText(responseAsXml)
// Loading ids into list
def allIds = []
xmlParser.tr.each{ result ->
allIds << result.td.a.text()
}
// Pass the next value into the ID property each time
allAccountIds.each{ id ->
result["ID"] << id
}
It will correctly give me those three values one by one, but then it will keep looping forever giving me blank values. I tried a number of different ways of passing the values into 'result' but nothing changed the situation.
I also tried just directly grabbing the values but no difference (example of that below)
xmlParser.tr.each{ result ->
result["ID"] << result.td.a.text()
}
Any advice on how to stop this infinite looping/passing in of blank values forever would be great.
EDIT: I also tried to match basically exactly what the example they give you does
// Loading in ids into list
def allIds = []
xmlParser.tr.each{ result ->
allIds << result.td.a.text()
}
// Pass the next value into the ID property each time
if((row +1) <= allIds.size){
result["ID"] << allIds[row]
}