I have a web based application that I am testing. There are a number of different webpages in the application and I have created a seperate action for each webpage. I need to run the frst two actions once then run Action 3 on all rows in the datatable.
The first two actions (Action1, Action2) run once, Action 3 is then set to run on all rows. The script flow runs correctly but when it gets to the second iteration of Action 3 it remains on row 1 of the datatable.
Any ideas how I can get the Action 3 (with it's nested actions) to run on all rows in the databale correctly?
Re: Looping through Datatable using nested actions
Where is the datatable? Global, or is it the Action3 datatable?
I try to never use the global data table, except to store values I want to pass to other actions.
If your data is in the Action3 datatable, have you set the Action Call property to run on all rows?
Allowing QTP to iterate through all rows of each datatable in each action is a nice feature of QTP, but it can be a hassle to set up. Remember, the settings in the menu Test/Settings dialog control the global datatable, and the settings in the menu Step/Action Call Properties dialog control the action.
Another way (to avoid the hassle or just because you are a control freak like me and don't want to let QTP handle it) is to control it programmatically. Make sure it's set for Run One Iteration Only then do your own looping through the datatable:
'Captures the number of rows in the Run-time DataTable
RowCount = DataTable.GetSheet("Action3").GetRowCount
For CurrentRow = 1 to RowCount
'Sets the active row in the Run-time Data Table to the iteration in the For..Next loop