1 Edit Menu
In Edit Menu, the first 7 commands are very self explanatory, which you can find in any GUI based application. You will find Undo, Redo, Cut, Copy, Paste, Delete, Copy Documentation to Clipboard (used for copying the documentation column value into notepad, ms word etc.).The below command are also very self explanatory and will get active when you are in Expert View mode. The commands are Find, Replace, Goto, Bookmarks.In this paper, we will cover Action (Split Action, Rename Action, Delete Action, Action Properties, Action Call Properties), Step Properties (Object Properties, Checkpoint Properties, Output Value Properties), Advanced (Comment, Uncomment, Indent, Outdent, Goto Function Definition, Complete Word, Argument Info, Apply “with” to script, Remove “with” statements) & Optional Step.
1.1 Action
As the name suggests, ACTION command can be used for doing manipulation on the QTP Actions. If you do not know what an ACTION is, then let me define for you. ACTION is building block concept in QTP. Whatever you are scripting is identified with an Action Name. ACTION provides a unique name to your Test Script. There is a reason behind introducing this concept in QTP. The ACTION enable to design a framework which can be made to re-used in your enterprise application. It provides a logical grouping of your Test Cases so that you can easily manage your Test Script. Test can consist either 1 action or multiple ACTION (reusable actions). We will cover these concepts in next series for Intermediate user level. Let now see the commands available under ACTION option.1.1.1 Split Action
Select the block of Test Steps in QTP which you want to SPLIT into 2 Action and then either right click or choose EDIT->ACTION>SPLIT. This will open a window where in you can specify whether you want the Actions as an Independent of each other or Nested. Specify the name of each action on the same window and then click OK. You have successfully SPLIT your Action. Now let me tell you its real time usage, you normally split action for doing a fast scripting. You recorded all the Step in 1 go and then SPLIT into ACTIONS so that you have the logical grouping of your test cases. The SPLIT option might not be enabled if:- Reusable Action is selected which is external in your Test (External Action)
- The very first step of your Test Script
- The Test open is Read-Only (anyway you cannot do anything except execution)
- Recording a test
- Running a test
1.1.2 Rename Action
This will be 1 of the very frequent command on your list. You need to rename your Action as per defined standard for your project and organization. To rename your action, press SHIFT+F2 or click EDIT->SPLIT->RENAME ACTION. You can also rename your action from the Action Properties Window. The default name given by QTP for Action is Action 1 and so on.1.1.3 Delete Action
You are also going to make use of this command whenever you want to delete other action (normally re-usable) in your Test Script. If you have included wrong re-usable action in your script and want to Delete it, then open the Reusable Action from Action navigation drop-down, click EDIT->SPLIT->DELETE ACTION. Please click Yes or No on the confirmation window to perform Deletion of your Action. I still wonder why this option never appears in right click menu. If you know the shortcut key for Delete Action, please share with us as well. I am having hard luck finding the short key for Deleting an Action.1.1.4 Action Properties
If you want to perform below activities on your Action, then use Action Properties window:1. Rename of an action
2. Making your Action a Reusable action
3. Specifying Input and Output Parameters specific to your Action
4. You want to associate or view the Object Repository for your Action.
5. You want to view the information that which all other Test are making use of your reusable action.
Let me give you some more insight into point number 3. In real time scenario, we normally use point 3 whenever we are creating reusable action. Parameter are normally not required for Independent Action. Usage of parameter will be covered in next level of my series.
1.1.5 Action Call Properties
You will find this option available only when your Test is using reusable action or nested actions. Using this command you can:1. Control the run of the called action
2. Provide the parameter value for the called action
Select the Reusable Action in Keyword View mode (remember you won’t see this option in the Expert View mode) and either Right Click and select Action Call Properties or Edit->Split->Action Call Properties.
1.2 Step Properties
1.2.1 Object Properties
If you know what an object in QTP, then its good but in case of you do not know, then let me define it for you. An object is a control (edit box, radio, check box, button etc), window, browser, page etc which has unique name, properties given by the developer and QTP identifies the object using those unique name or properties. As a scripter you should be able to read and understand the object properties. QTP provide Object Properties option to see the property of an object. Ready only information is displayed in this window but you can find that object in Object Repository from this window as well.First highlight the Object and then either press Ctrl+Enter or Alt+Enter or Edit->Step->Object Properties or Right Click and then select Object Properties.
1.2.2 Checkpoint Properties
Let first understand what a checkpoint is actually means in QTP. Checkpoints in QTP enable or pacify the process of test case validation. For e.g. if my test case is saying, validate that the QTP image is appearing on the web page, validate that Age Text Box is disabled by default. If you have to script above test cases, then you might require the Checkpoint in QTP. There are various checkpoints which are available in QTP but the most frequent one is Standard Checkpoint. We will cover QTP checkpoints in detail in next series.If your test consists one or more such checkpoint, then you can view the Checkpoint property by either selecting the “Check” keyword in Expert view and then Right Click and choose Checkpoint Property. You can also click the tick sign in Keyword View mode on the Test Step which correspond to “Checkpoint”. Using Checkpoint properties window, you can put validation for other properties as well. You can set the value to be Constant or make it Dynamic by parameterize the specific property.
1.2.3 Output Value Properties
This is similar to Checkpoint properties except that you are outputting the value from your AUT to make use of it for doing validation at some other steps in your test. We will separately cover this in next series. But you can view the Output properties in the same way as you viewed the Checkpoint properties. Select the Step which consists “Output Check”, select Edit->Step->Output Value Properties or Right Click->Output Value Properties.You can edit other properties as well so that it can be outputted to a spreadsheet. You can navigate to Object Repository from this window. Click the icon on right side of Name Text Box.
1.3 Advanced
1.3.1 Comment Block
To commend the block of code, select the block of code in Expert View and press Ctrl+M or Edit->Advance->Comment Block. This will comment the selected code. Used very frequently while doing scripting.1.3.2 Uncomment Block
To uncomment the block simply select the block and press Ctrl+Shift+M or Edit->Advance->Uncomment Block.1.3.3 Indent / Outdent
This is very self explanatory. You can indent and outdent your Test Script to increase readability. This make your Test Script look cleaner and make your script easily readable to other scripter. Always follow the defined Organization standard for Indenting and Outdenting.1.3.4 Goto Function Definition
This is very important command and you need to know this as this will come very handy when you are analyzing the existing script which is making use of function. This command will simply take you’re the function definition. Remember from 2nd series we have included library files in our test. Those library files is a collection of various functions which my Test will make use of. If my test is making use of function whether internally or externally, I can always see the definition. Select the Function Name, Right Click->Goto Function Definition, or Edit->Advance->Goto Function Definition or press Alt+G.1.3.5 Complete Word
This is again very simple. If you writing a code say Dialog, the instead of typing complete word, you can type initial and then either press Ctrl+Space or select Edit->Advance->Complete Word. The former is more frequently used and I do not know why HP has still given this option in the Edit Menu.1.3.6 Argument Info
To see the Argument of a function whether in-built or external , type the function name and then press Ctrl+Shift+Space or Edit->Advance->Argument Info.1.3.7 Apply “With” to Script
You can make your script look more readable with “With” statements. To apply the script with “With” statement, simply press Ctrl+W. This will convert the script into “With” statement. See the below screen shot for clarification.1.3.8 Remove “With” Statements
If you want to remove the With Statement and revert to its original format, press Ctrl+Shift+W and your script will be removed with all the “With” statements.1.4 Optional Steps
The decision to make a step optional entirely depends on your application design. There may be instances where you application perform some action based on saved value in session. For e.g. Remember Login feature. You can make the Test Step for Login as an Optional Step. To make a Step optional, go to Keyword View and then select and right click on step and select Optional Step. You can also go Edit->Optional Step. This step will showAn optional step is not necessarily required to successfully complete a run session. If object of optional step does not exist in AUT, then QTP ignores it and continue with the test.
By default, QTP considers steps that open the following dialog boxes or message boxes as optional steps: AutoComplete, File Download, Internet Explorer, Netscape, Enter Network Password, Error, Security Alert, Security Information, Security Warning, Username and Password Required.
Comments