A gentleman recently sent me an e-mail asking a question about DataTables:
1. Why DataTable.GetRowCount and DataTable.GetCurrentRow are not working properly in some of the tests scripts, 2. here the values are placed into the datatable from the weblist during the runtime.... is it becoz of that or any other settings required to retrieve the rowscount in the test thank u in advance I suspect the problem might be an issue with the Global vs. Local sheet, so I have replied with the following:
Hi! It's difficult to say why GetRowCount and GetCurrentRow aren't working, but here's what I would check: Is the data located in the Global or a different sheet? The methods for the DataTable default to using the Global sheet. In order to use those for other sheets, I find it easiet to grab the sheet specifically like this:
Dim oSheet
Set oSheet = DataTable.GetSheet("ActionName") 'I can use the methods using oSheet msgbox oSheet.GetRowCount
Populating the DataTable dynamically should be fine; you should be able to use GetRowCount anytime and get the correct number of rows. I tend to avoid using the DataTable, but I have never really seen the GetRowCount/GetCurrentRow not give accurate results when I ask for the right parts. I have created an example to illustrate what I mean. Create a new test and add two Actions. Place Data (10 rows in my example) in the Global sheet in column A, and similar Data (5 rows in my example) in the Action1 sheet, but a different number of rows. Then add the code to the correct action:
'Action1 code
DataTable.SetCurrentRow(11)
'Since we are pointed to the DataTable, it assumes global DataTable("A", dtGlobalSheet) = "11" 'We change the value in the the 11th row
'Action2 code
Dim oTable
Set oTable = DataTable.GetSheet("Action1")
msgbox datatable.GetRowCount
msgbox oTable.GetRowCount
msgbox DataTable.GetRowCount
If you run this, you'll see that oTable.GetRowCount gives you the Action1 count, and DataTable.GetRowCount gives you the global. If this isn't the problem, then I'd contact Support. Hope this is helpful.
Theo
posted @ Friday, November 03, 2006 8:12 AM