Working with Actions in QTP


Actions:
I) Actions are very similar to functions. Except few differences rest of all are same.
II) Action is a set of logical related statements.
III) Actions help to divide a lengthy script into smaller script.
IV) Based on the order in test flow execution of Actions happens sequentially.
v) For every Action or sub action one Object Repository will create.

How to insert an Action
ActionàCall to new Action
If two actions are called from test then those actions are set to be independent actions.
If two actions are called within the Action, then those two Actions set to be nested Actions.
Action is a collection of VB statements in QTP. It does not return any values.
We can’t call actions within the functions.
Generally Actions will save with “.mts “
By default QTP records all steps into an Action.
Actions can contain Object Repository, Data Table, and Active Screen etc.

Actions are two types
1)Reusable Actions
2)Non Reusable Action
1) Reusable Actions: We can Reusable Action Script in other test. They can be used in the same test script multiple times.
How to create Reusable Actions
By default all Actions are Reusable Actions Only.
ActionàCall to new Action

2) Non Reusable Actions: Non Reusable Actions cannot be used in other script. They can be called the same script only once.

How to create Non Reusable Actions:
ActionàCall to new Actionà check Non Reusable Action

In Actions there are two methods to import Scripts in to a code. Call to
1) Call to Copy Action
2)Call to Existing Action

1) Call to Copy Action: When we make a copy of an Action the Action is copied in its entirety, including checkpoints, Parameterization and datatable into calling test. When we insert a copy of an Existing Action we can able to make changes to the copied Action. And our changes will not affected by the original script and any other test. We can insert both Reusable Actions and Non Reusable Actions.

     How to create Call to Copy Action
Click on Edità Call to Copy
2) Call to Existing Action: Call to Actions is read only in the calling test. They can only be modified in the test in which they were created.  In Call to Existing Action we can insert only Reusable Actions.

How to create Call to Existing Action
Click on Edità Call to Existing