Noob here. I did a search and couldn't find any solution to this:
I'm using VBscript functions instead of actions. In my test, i use 3 datatables:
Global - To determine what test scripts to run for different products (Sheet1, Sheet2, Sheet3....etc.)
Sheet1 - Actual test scripts to run for product A (Step1, Step2, Step3...etc.)
Sheet2 - Actual test scripts to run for product B (Step1, Step2, Step3...etc.)
When my test begins i would like to read the Global datatable and locate the Sheet to run (eg. Sheet1), then read the appropriate Sheet and iterate through that Sheet and run the steps. When it is done with the first Sheet, it moves on to the next Sheet on the Global datatable (eg. Sheet2) and then does the same thing.
1) I can't figure out a way to loop through the other sheets without writing a loop myself. QTP's loop functionality only seems to serve the Global datatable.
2) Test Results - The default test results feature in QTP only reports the pass/fail status for each iteration in the Global datatable. I would like to have it report for the other Sheets as well.
3) Error Handling - I have the test settings set to proceed to next iteration when an error occurs. During run time, the test moves to the next iteration on the Global datatable instead of the next iteration on the action sheet as intended.
Maybe i'm just missing something here. But i have searched the forum extensively and also the user guide with no success. Any help would be greatly appreciated.
try right clicking on the action in the keyword view and selecting action call properties- that should display a datatable iterations dialog. select run on all rows or a defined range. Conceptually, the way to iterate through all your sheets is to associate each sheet with a separate action, QTP does this by default as it adds action tabs to the datatable.
My Main action is a simple script that has a datasheet called "Main". This datasheet has only two columns. The first column contains "yes" or "no", the second column is the name of all the other actions in the script.
I get the rowcount of the "Main" datasheet, then loop for i = 1 to that rowcount.
Inside the loop I use SetCurrentRow to set the row of "Main" = i, then I check column 1 to see if I should run that action or not. If it is "yes" then I run the action named in in column 2. Note that I always run just one iteration of these other actions.
Each action begins by getting its own row count and then using a for..next loop with a SetCurrentRow statement to loop through its own datasheet.
Note that you may need to use the GetSheet method in many of your DataTable statements. For example: DataTable.GetSheet("sheetname").SetCurrentRow (i).
To answer your three Problems:
1. Yes, write your own loop. If you let QTP manage your iterations, you must do so at your own risk.
2. I am not sure why this is happening for you, unless it's related to problem 1 - fix problem 1 and see if you have the same concern with problem 2.
3. You can handle much of this within your loop. Use GetROProperties and If..Then statements to control your error handling. Do not use the test settings to go to the next iteration since you are running these actions as one iteration only.
This framework works really well for me. I can use the first column of the "Main" datasheet to turn the other actions off and on very quickly. I can use similar funcitonality in the datatables of each of my reusable actions to turn individual rows off and on very quickly (I do this to exempt certain rows for various reasons, such as when I just want to debug rows 25-30, I can turn off the other rows in just a few seconds -- or I can edit my for..next loop). It gives you a great deal of very flexible control over all your actions and their iterations.
"The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"