For beginners of QTP, it is very important to understand the difference between Action and the Test.
A QTP Test can have multiple Actions. The Actions can be arranged in nested manner (parent action-child action) also within the Test. Each Test will be stored as QuickTest Test. Actually it will be shown as Folder in windows explorer. Each Folder will have many files and many sub folders (one separate sub-folder for each Action).
Refer the below screenshot
So it is clear that Actions are part of Test.
DataTables in QTP are used to enhance the script by doing Datadriven testing easily.
Refer the below screenshot.
The Datatable is having One Global Sheet and several local sheets based on number of Actions used in the Test.
The Global sheet is used for storing the data used for Test Iteration, and the local sheets are used for storing the data related to corresponding Action iteration.
The Test Iteration can be specified from Run tab of Test Settings (File->Settings).
The Action Iteration can be specified from “Action Call properties” window which can be opened from Right click menu (context menu) of the particular Action.
Now the next step is when we should use both Test iteration and Action Iterations.
Assume that you are testing flight booking application which comes along with QTP installation.
You need to test different test cases of booking tickets 5 times.
So, we can easily do it by entering the ticket details in 5 rows of Action sheets and setting “Run on All Row” in “Action Call properties”.
We know that we need to login into the application before booking Tickets.
So now the tickets will be booked 5 times with single user login.
Assume that we need to test this with 4 different users.
So, we need to book the tickets 20 (5×4) times.
It can be handled by using both Test Iterations and Action Iterations.
The user login details can be kept in the Global Sheet and the “Run on All Row” should be set in the Test settings.
So now script will execute 20 times to make 5 bookings with 4 user logins.