January 18, 2012


QTP provide a very powerful feature of dividing the test into actions. It is recommended that if the script is going to be too large, divide it into actions. But try to complete your script in minimum number of actions.

Action Properties:
By default actions are named as Action1, Action2,...etc. We can rename and give description about action in Action Properties at Edit Menu >> Actions >> Action Properties >> General tab.
Action Properties gives facility of creating input/output parameters and also lists the associated repositories.

Types of Actions:
Non-Reusable Actions  - An action that can be called only in the test with which it is stored. These are also called Internal Non-Reusable actions.
Reusable Action - An action that can be called multiple times by the test with which is stored as well as by other tests. When used in the original test(where these are stored) these actions are called Internal Re-Usable actions.
External Action - When a re-usable action is used in any other test, then it becomes external action for that test.

How to make an Action Re-Usable?
Action can be made reusable in Action Properties but we can access action properties from three locations.
1. Edit Menu >> Actions >> Action Properties. Here check the "Reusable Action" checkbox.
2. Right click in Expert View >> Action Properties. Here check the "Reusable Action" checkbox.
3. Right click on action name in Keyword view >> Action Properties. Here check the "Reusable Action" checkbox.

How to split an action into two different actions?
Click on the line from where you want to split your action and then
1. Edit Menu >> Action >> Split Action.  OR
2. Keyword/Expert View -- Right click >> Action >> Split.

Action & Object Repository:
Each action maintains its own object repository. It is called Local Object Repository to that action. Here we can Cut, Copy, Paste, Modify and Delete the objects. The changes made in its local object repository will be applicable on that action only.
When we run an action, QTP looks for the objects in the action's local object repository first.

Calls to Actions:
Call to New action: It adds a new blank action to the test. To call to new action, right click on expert view select action and then select Call to New Action option.
Call to Existing Action: It adds an existing reusable action of current or any other test to the test. These called actions are not editable but the changes done in the original action will be reflected here in currect test.
Inserting Call to Existing Action  adds a code line RunAction "Action2",OneIteration in expert view.
We can not add this code line without first following the steps specified above. And deleting this code line still keeps the action call information in the test. To completely delete all information from the test, the keyword view should be used.
Call to Copy of Action: It adds copy of a reusable or non-reusable action from current test or any other test.These actions are editable and the changes made here will not reflect in the original action.
The copied action comes with its checkpoints, Parameters, corresponding tab in DataTable, any action parameters, and also its local object repository.
If the test into which we are using a shared OR, the copied action will then use that shared Object Repository.
The copied action is inserted into the test as an independent, non-reusable action, even if the original action was reusable.