Monday, December 31, 2012

Actions in QTP


As mentioned by QTP, Each QuickTest test comprises calls to Actions. Actions are units that divide your test into logical sections. When you create a new test, it contains a call to one . By dividing your tests into calls to multiple actions, you can design more modular and efficient tests. 

-Actions help divide test into logical units, such as the main sections of a Web site, or specific activities that you perform in application. 

-A test comprises calls to actions. When a new test is created, it contains a call to a single action. By creating tests that call multiple actions, can design tests that are more modular and efficient. 


-An action consists of its own test script, including all of the steps recorded in that action, and any objects in its local object repository.

-Can divide test into multiple actions by creating new actions and inserting calls to them, or by inserting calls to existing actions.


There three types of action in QTP:
 
  Non-reusable action: an action that can be called only in the test with which it is stored, and can be called only once.
  Reusable action: an action that can be called multiple times by the test with which it is stored (the local test), as well as by other tests.
  External action: a reusable action stored with another test. External actions are read-only in the calling test, but can choose to use a local, editable copy of the Data Table information for the external action.


A reusable action can be called multiple times within a test and can be called from other tests. Non-reusable actions can be copied and inserted as independent actions, but cannot be inserted as calls to the original action.
** Priority in Object Repository

Call an action from within an action called nesting. 
Maintain the modularity of your test.
Run one or more actions based on the results of a conditional statement.

Example
Create test based on the user type

To nest an action within an existing action:
Highlight the step after which to insert the call to the action.
Insert Call

Split Action
Split an action into two sibling actions or into parent-child nested actions. When an action is split, the second action starts with the step that is selected. 


Can’t split an action and the option is disabled when:
-an external action is selected
-recording a test
-running a test
-read-only test

Inserting Calls to Copies of Actions


When to use?
    It is best to use this functionality
When the action can be partly used with the associated resources through edition of test steps and likely to be standalone test unit.
When the user knows that this functionality is likely to change in the future hence doesn’t want to be reusable.

Inserting Calls to Existing Actions


When to use?
    It is best to use this functionality
When the functionality in the action can be completely used in another action such as a Login.
When the user likely to maintain a reusable actions for easier maintenance.

Remove Action

 
Removing a Non-Reusable Action
Removing a Call to a Reusable or External Action from the Test Flow
Removing a Reusable or External Action from a Test


Action Template:

Action template can include one or more statements in every new action in test. An action template applies only to actions created on your computer.

To create an action template: 


Create a text file containing the comments, function calls, and other statements that to be included in action template. The text file must be in the structure and format used in the Expert View.
Save the text file as ActionTemplate.mst in your <QTP Installation Folder>\dat folder. All new actions you create contain the script lines from the action template.


Note: Only the file name ActionTemplate.mst is recognized as an action template. 

RunAction:


RunAction is the key word to call an existing actionand execute the same

Syntax: 
RunAction ActionName, [Iteration , Parameters]
Eg:
1.RunAction “Create", allIterations
2.RunAction “Login", oneIteration, Parameter
retVal = RunAction (ActionName, IterationQuantity, Parameters)

Exit Action:

 
Exit an action before it runs in its entirety. May want to use this option to return the current value of the action to the value at a specific point in the run or based on the result of a conditional statement.
ExitAction. Exits the current action, regardless of its iteration attributes.
ExitActionIteration. Exits the current iteration of the action.
ExitRun. Exits the test, regardless of its iteration attributes.

LoadAndRunAction Statement: 

 
This is only available from QTP 10.0 +
Loads the specified action when this step runs, and then runs the action.
The action is loaded only when the step runs (and not when the test opens). Therefore the action is never listed in:
The Resources pane in QuickTest.
The Test Flow pane in QuickTest.
The Missing Resources pane in QuickTest.
The Dependencies tab in the Quality Center Test Resources module.
 

Syntax:
LoadAndRunAction(TestPath, ActionName, [Iteration], [Parameters]) 


 

4 comments:

  1. This content creates a new hope and inspiration with in me. Thanks for sharing article like this. The way you have stated everything above is quite awesome. Keep blogging like this. Thanks.
    Best Digital marketing company in Chennai
    Best Digital marketing services in Chennai

    ReplyDelete

  2. thanks for the information it will one of the good blog, i need more news from this topic.
    Back to original

    ReplyDelete
  3. Pretty article! I found some useful information in your blog, it was awesome to read, thanks for sharing this great content to my vision, keep sharing..
    Android App Development Company
    iOS App Development Company

    ReplyDelete
  4. Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. project management courses in chennai |pmp training class in chennai | pmp training fee | project management training certification | project management training in chennai | project management certification online |

    ReplyDelete