What are actions in QTP?
Actions divide the test in to logical sections, while creating a new test, it contains only one action, by dividing the tests into multiple actions, more modular and efficient tests can be designed, in general, Actions are
It gives the best way of grouping separate codes into business logic
Are pretty similar to Functions in VB Script
It has its data Table and Object Repository (in case of per action Object Repository)
Supports input and out parameters
Normal Action –Is a default Action for a test, this type of action cannot be called for other tests, can be used only in the current actions.
Reusable Action –Just an opposite of normal action, it can be called in other QTP tests.
QTP doesn’t not allow calling another test within the test , Test flow represent the top level action, Complete test flow can only be viewed in Keyboard views.
To divide the test in to actions, a new action can be inserted, an existing action can be split into two actions, an existing action can be copied, or an existing action can be called, A new action can be inserted in to test during recording session or afterwards, one of the following menu options or toolbar buttons can be add actions to the test.
Three ways to insert action into a test.
Insert Call to New
Insert Call to Copy
Insert call to Existing
Insert call to New Actions:
From Menu Insert ->call to new action creates a new action and adds a call to the same
Adds below line to the code
RunAction “Cancel Ticket”, oneIteration ‘For cancelling the ticket’
Actions –Insert Call to Existing Action
Insert Call to Existing –User needs to insert to a reusable action located within the same test or some other test, only reusable actions can be called.
This includes the call to the existing action; in case the action is present in some other test case then a read only copy of action is inserted
Actions –Insert Call to Copy of Action
Insert Call to Copy –Inserts call to an existing action and creates an editable copy of that action
Actions cannot be deleted from a test from expert view, To delete a action one must go to the keyboard view and delete the action
Calling an action cannot possible by directly entering into Expert view, it should be added by GUI.
How to rename an action
Select the desired action in the action dropdown and use a shortcut (SHIFT+F2) or From Edit Menu ->Action ->Rename Action
How to delete an Action
To delete an action From Edit Menu->Action->Delete Action
How to convert non reusable action in to reusable action
Select the desired non reusable action from the dropdown, From Edit menu ->Action->Action Properties General Tab->Check Reusable Action and click ok
How to do Split Action
Let’s take an example of login and logout of QTP
- Record Login script of Flight reservation
- Edit Menu->Action ->Split Action->Click Independent of each other to maintain separate actions
- Use Nested action to split it, Enter Action1 name and Action2 name
How to change Action Frequency:
To Change Action Frequency File->Settings->In Test settings->Run tab ->Select Run one iteration only, By default it is Run all rows, in this Tab you can control From which row to which row should execute by selecting “Run From row” Enter 1 to 5