Actions in UFT/QTP.
Actions:- Actions are a set of logical/ business statements. What is logical/business statement? Let’s take an example of Gmail now in this Login, composing an email, forwarding an email, logout are the logical/business component. Actions help us to divide your test into "logical units" or "Business Processes". Actions help create a script which is more modular and efficient. To understand in a better way, let’s take 2 approach for writing 100 automation scripts for Login -> Composing an email -> Logout of gmail application:- 1st Approach:- Where you will write the code in a linear format i.e writing the whole code of login thereafter the code for composing an email and then Logout code, now in the same way you will be automating the other 99 test scripts. 2nd Approach:- First you divide the application into multiple business flow and then writing the code for each business flow separately like code for Login, code for Composing an email, code for Logout, that means now you have 3 business component, which is separate to each other. Once separated you just need to call it in a new test. Now you need to think which approach you will opt for automating this requirement? Still Thinking? You are right the 2nd Approach is good to use, let’ talk about the advantages of 2nd approach over the 1st one. 1.In the 1st approach, high volume of redundant code is available as you have written the same code of Login, Composing an email & Logout, for all the 100 test cases, whereas in the 2nd approach we just created once the code for all the business component and in all the 100 test cases we are just calling it and using it. 2.Using 2nd approach, Script maintenance will be easier, let’s say I need to add one line of code in the login code, now if you use the 1st approach you need to open all the 100 test cases and need to add this line of code this is tiring and time consuming work, whereas in the case of 2nd approach you just need to add the line of code in the business component and save it , now all the test cases which are calling/using the login component the change will reflect automatically in their test cases. Isn’t you save lot of efforts? I hope after reading above points you will be able to answer the following questions? Q1-What is actions? Q2-What is the importance of actions? Q3-Wht is the advantage of actions? Now let’s proceed and see little more inside about the actions:- Diagram There two types of Actions Reusable Actions: can be used in other Tests. They can be used in the same Test script in multiple times as well. Reusable Actions are further classified into:- Call to New Actions. Call to Existing Actions. Call to Copy Actions. Call to New Action: This is a reusable actions, when you create a new actions in the test then it can be called from any other test. Call to an Existing Action: Calls to existing actions are read-only in the calling test. They can only be modified in the test in which they were created. Enables you to use the same action in several tests and makes it easy to maintain tests. You can make calls to only "Reusable" actions. Call to Copy of an Action: When you make a Copy of an Action, the action is copied in its entirety, including checkpoints, parameterization, and the corresponding action tab in the Data Table into the calling test. When you insert a copy of an existing action, you can make changes to the copied action, and your changes will not affect nor be affected by any other test. You can insert copies of both reusable and non-reusable actions Non-Reusable Actions: cannot be used in other Tests/ call by any other test. They can be called in the same script only once. When a script is newly created it consists of only one action. But you can add more Actions to your QTP Script as per requirements. Actions can access test-data stored in datasheets. QTP provides 2 type of datasheets GLOBAL Datasheet: It is Unique for the entire test. Any Action can access and write data into Global Datasheet. Sheet is named "GLOBAL" LOCAL Datasheet: Equal to number of Actions in the sheet. An Action can read and write data into its own local Datasheet only. Sheet name =”ACTION NAME". The entire purpose of creating Actions is to use them in other Test Scripts. At times, if an action becomes big, it’s a nice practice to split it. You can split an existing action in two ways Independent of each other which splits the selected action into two sibling actions Nested Action which splits the selected action into a parent action whose last step calls the second, child action Points to remember:- 1. Analyze the application thoroughly and then try to create as much of actions you can create for application. 2. It is recommended to use Call to Existing actions because it will make your script maintenance easier. 3. Enter all the data of actions corresponds to their action data sheet. Let’s say for Login action put all the data in the Action data sheet. 4. It is recommended that in Global sheet, enter only those data which can be used across all the actions. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |