Thursday, May 31, 2012

Actions in QTP

  Happy to see you through this article. Actions!.. The name itself explain what it's going to do. Well, Actions are block of script that going to perform a specific action or operation in a test. We can rather say an Action is a function but actions have it's own object repository and DataTable sheet. A test may contain more than one action. An automation tester can decide what are all the events should be put in a action. Even though it's not complex, this single post is not enough to explain everything about Actions. Let me try to furnish as much as details I could accomodate in this post.
There are two types of Actions in common.
     1.  Reusable Action.
     2.  Non- Reusable Action.

 
Reusable Action:
    These actions can be reused in any place in the test. We can call the reusable action from another action. To mark an action as reusable, select the 'Reusable action' checkbox in the action properties. If we uncheck 'Reusable action' Checkbox it will become Non-Reusable action.


Non-Reusable Action:
   These actions can not be reused. We cannot call a non-reusable action from another action.





Creating an Action / Call to an Action :
    In QTP, we can create a new action, copy another action from different test/same test or we can create a call to exiting action in different test/same test.
Call to New Action...:
   Through this way we can create a new action. Also, It will create a call to new action from the action it's being created. We can either select "Call to New Action..." option from toolbar or from Insert menu. This will open the 'Insert Call to New Action' dialog. If we select 'Reusable Action' checkbox then the new action going to be created will be a resuable action.
There are two more options to choose where the call for the new action to be inserted.
  After the current step - Call to the new action will be created after the current step in the current action. So while executing the test, New Action will execute after current step.
  At the end of the test - Call to the new action will bve created at the end of the test. So New action will be executed after the execution of all the existing action.


Call to Copy of Action...:
  We can use this option when we want to create copy of an action (The copied action present in the current test directory). We can copy the action either from the same test or from another test. This option will create a copy of the action in the current test. Any changes in the copied action will not affect the original action.
   When selecting the 'Call to Copy Action..' option, "Select Action" dialog will be opened. By default, all the actions associated with the current test will be listed.
   If we select "Edit new action properties" check box in 'Select Action' dialog, Action properties dialog will be opened on clicking the OK button.
There are two more options to choose where the call for the copied action to be inserted.
  After the current step - Call to the copied action will be created after the current step in the current action. So while executing the test, copied Action will execute after current step.
  At the end of the test - Call to the copied action will bve created at the end of the test. So copied action will be executed after the execution of all the existing action.



Call to Existing Action...:
   This option will just create a call to the existing action without copying it. If the original action is modified, it will affect all the places where the action is called. When selecting the 'Call to Existing Action..' option, "Select Action" dialog will be opened. By default, all the actions associated with the current test will be listed.
   If you are creating a call to an Action from another test, it will be called as "External Actions". Actually, these External actions are read-only in the calling test. But you can use the local editable copy of data table for these external actions.

Thursday, May 17, 2012

:: LoadAndRunAction ::


    LoadAndRunAction is the new feature in QTP that indroduced in the version 10.0. This method is used to load the action dynamically during run time.


   In the above picture, you are seeing that we can insert call to an existing Action. Actually, it will create links to the corresponding action before we start executing the script. You may have 100 Actions already mapped or linked to the driver script. But you going to run only the 10 actions. In that case, the remaining 90 actions will be loaded before the execution but actually those actions will not be executed. So,What If you want to load the action based on your need?
Here is the way to Load actions during run time. LoadAndRunAction method is used to load only the required action during run time. This will help you to save more time when you have more number of actions and you want to execute only few out of it.

How to Use:
    Syntax:  LoadAndRunAction "Test Name with path", "Action Name"
          Ex:  LoadAndRunAction "C:\Automation Scripts\Test1","Action1"

LoadAndRunAction load any reusable external action from another test during run time.