Forum Discussion
- LZhangFrequent ContributorAny update on this?
Thanks,
Li - Hi Li,
you would need to do this with groovy, do you want an example?
regards,
/Ole
eviware.com - LZhangFrequent ContributorHi:
I have a property step in which it stores only StartDate (14 rows total). The value for each StartDate is in UTC format: 2009-06-24T13:58:26Z. My goal is to transfer all these 14 StartDate
into the next step which is a datasource Grid type so I can loop this datasource later. The 14 StartDates are in increment:
2009-06-24T13:58:26Z
2009-06-25T13:58:26Z
2009-06-26T13:58:26Z
2009-06-27T13:58:26Z
2009-06-28T13:58:26Z
.....
That's why I need a datasource to loop. Please provide me with an example how I can accomplish this. Thank you.
Li - LZhangFrequent ContributorCurrently, I found an indirect way to do this, i.e, to output all the startDate to an external file using groovy and then in the next Datasource step, read those startDate back in as file and store them in
the datasource.
I just wonder if there's a quicker/better way of doing this transfer between Property step and Datasource.
Thanks,
Li - Hello,
I wrote a script that allows you to directly modify the Grid DataSource from Groovy:
model = testRunner.testCase.testSteps['DataSource'].dataSource.gridModel
def appendRow(String... data) {
def row = model.rowCount - 1
for(i in 0..(data.length-1)) {
model.setValueAt(data[i], row, i)
}
}
//Clear the grid
model.deleteRows(0..(model.rowCount-1) as int[])
//Insert data
appendRow('Hello', 'World')
appendRow('Goodbye', 'Moon')
Replace the first line with one that correctly targets your Datasource.
To use this the Grid DataSource needs to have the proper columns set up ahead of time. Each call to appendRow takes a number of Strings, at most the same number as there are columns available. Hope this helps!
Regards,
Dain
eviware.com