I would like to know how can I make the script run for different iterations fetching data from the data table for every iteration.
For example:In the mercury tours website, there is a field called as trip type for which the value is either 'Round trip' or 'one way'. I have created a data table called as action2 for 'Trip type'. I have also put a for loop for my code to run 2 times. But both the times it does not pick up the values from the data table. Can somebody help me to resolve this?
If you use datatable for parametrization, you should not use loop in your script. If that is a complete action, just take out the for-loop, and make sure QTP is set to run "all iterations" or rows 1 to 2.
If there is a reason to use a loop and not "built-in" way of iterating with datatable, you can specify which row in the datatable your script should use. I do not have QTP at hand, but there's a parameter to set current datatable row used by the script. Datatable row in your case would be i+1 inside the loop.
I removed the for loop from the code. I have created the data table using the wizard. I have set the QTP settings to run 'all iterations'. Inspite of all this it runs only once. There is something which I am missing to do and I don't know what it is.When I create the datatable it gets created in the global sheet and not in the action sheet. Is that causing the problem? Please see the attached screen shot for the code and the datatable.