Looping through datasource and xml response in Groovy
Hi,
I have an Excel DataSource containing more than 12000 records with only the properties AdvisorIds and AdvisorNames. I also run a Soap request with a response containing the same records. Now I want to cross-reference the DataSource with the Soap Response. I started writing a groovy script to do this. I used some information from this post: https://community.smartbear.com/t5/SoapUI-Pro/Looping-a-Datasource-in-Groovy-script-Always-starts-at-last-row/m-p/101531#M23905 :
def response= context.testCase.testSteps["GetAdvisors2"].getPropertyValue("response").toString()
def xmlResponse = new XmlSlurper().parseText(response)
def countAdvisors = xmlResponse.advisor.size()
dataSource = testRunner.testCase.getTestStepByName('DataSource').repositionAtStartRow(testRunner, context)
for (row in 0..dataSource.rowCount -1){
if (row > 1)
{
testRunner.testCase.getTestStepByName('DataSource').Next
}
def dataSourceAdvisorsId = dataSource.getPropertyValue('ADVISORID')
def dataSourceAdvisorsName = dataSource.getPropertyValue('ADVISORNAME')
for(i=0; i<countAdvisors; i++){
def advisorIdXmlResponse = xmlResponse.advisor.id[i].text()
def advisorNameXmlResponse = xmlResponse.advisor.name[i].text()
break;
}
log.info "AdvisorsId xmlResponse = " + advisorIdXmlResponse
log.info "AdvisorsName xmlResponse = " + advisorNameXmlResponse
assert dataSourceAdvisorsId == advisorIdXmlResponse
assert dataSourceAdvisorsName == advisorNameXmlResponse
}
Unfortunately the rowCount method returns 1 instead of 12000. The loop for the xmlSlurper (starting with for(i=0; i<countAdvisors; i++){) is working and looping through the Ids and Names. Is there a way of using this groovy script to get both al the rows from the DataSource, iterate through it and at the same time iterate throught the Soap Response?
Thanks in advance!