This is the subsequent tutorial as part of our QTP Training series.
=> Head Over To QTP Training Tutorials Series
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
This post gives an insight into the Keyword View offered by the QTP GUI. We will put forth a brief overview of Actions, Object Hierarchy, and the essential columns that constitute the keyword view.
So, let’s embark on our journey!
Familiarizing With the Keyword View in QTP
At the top, you will find a drop-down box displaying “Action 1”.
What interpretation does this carry?
Understanding Actions: Actions are the building blocks of tests in QTP. An action is essentially a series of instructions that execute a specific set of tasks. Actions introduce modularity and can be invoked by a test to perform certain tasks.
For instance, Let’s consider we have an online email system where the user is required to complete tasks such as logging in, composing and sending an email, and finally logging out. In such a case, it is advisable to segregate these tasks into isolated actions, even though they could be combined into a single action.
The “Email Test” will include:
Action1 | >Login |
Action2 | >Compose and Send Email |
Action 3 | >Logout |
The subsequent actions in the test will be triggered as follows:
Invoking Action1; Invoking Action 2; Invoking Action 3
If these tasks were combined into a single action, it would lead to a lengthy script which would be quite tedious to manage and maintain. Breaking these tasks down into actions improves manageability and they can also be parameterized to reiterate a specific task multiple times.
Whenever a new QTP test is developed, it automatically carries a reference to “Action 1”.
Expanding the drop-down unveils the Test Flow. For tests comprising multiple actions, the Test Flow specifies the sequence of calls to each action. This aids in easy navigation and editing of actions.
There is also a “Reusable Actions” directory view. Reusable actions can be invoked multiple times within the same test and across different tests. By default, every action is reusable, but this setting can be modified if required.
Now, let’s move ahead and talk about the object acknowledgment hierarchy in QTP.
Object Hierarchy: QTP utilizes a tree hierarchy to store objects. In our example here, the Agent Name and Password are child objects for the Login object container (which is a dialog box). Container objects can be windows, dialog boxes in Windows-based environments, or web pages in a web-based environment.
Brief overview of the Login Dialog in the flight application:
In this instance, the Login dialog is the container object, and the child objects include Agent Name, Password, along with other buttons and images present in the dialog. The overall hierarchy can have multiple levels, such as browser.page.button – where the browser encapsulates the page and the page, in turn, encapsulates the button.
Efficiently Dealing with Keyword View
In this fragment, we will reiterate the test we recorded in the previous post. We will initiate the flight application, enter the Agent Name and Password on the Login Page followed by clicking on OK.
We will also append a few function calls and statements manually from the Expert view and observe their appearance in the Keyword view.
Here’s the code I integrated into the expert view:
Dialog("Login").WinEdit("Agent Name:").Set "swati" Dialog("Login").WinEdit("Password:").SetSecure "5112fd3c42beb7a58069b67cfdd9b7e7ad1fc69c" Dialog("Login").WinButton("OK").Click msgbox "text" If x=0 Then msgbox "text 2" End If Window("Flight Reservation").ActiveX("MaskEdBox").Type "010312" Window("Flight Reservation").WinComboBox("Fly From:").Select "Denver" Window("Flight Reservation").WinComboBox("Fly To:").Select "Frankfurt"
Lines 1 through 3 denote the login procedures. Line 4 is a function referred to displaying a message box. I integrated a dummy ‘if’ declaration to display how it looks in the keyword view. The variable “x” is also a dummy variable.
Since we are not intending to run this test, we will utilize it purely for theoretical aspects. Lines 8 through 10 capture the flight date in the “from” and “to” fields to demonstrate object grouping.
This is how the code appears in the Keyword view: [click on any image to view magnified version]
On careful observation, one can note four columns, namely: Item, Operation, Value, and Documentation. One can expand or collapse the table by clicking on the small arrow next to the action name.
Item: Each step depicts a sequence of activities performed on an item. The items can be test objects, utility objects, statements, or function calls.
- As an example, the Agent Name Edit box is a test object.
- Utility objects are reserved by QTP and employed in tests. Such as, the DataTable object.
- Statements could be VB Script programmatic statements or comments.
- Function calls correspond to calls to functions like ‘msgbox’ in our scenario.
Operation: This refers to the operation acted upon the item. Clicking on this column for a particular item reveals all the available operations for that object.
Value: This column specifies the argument of a statement. For instance, the message box function call has the value “Text”. If a statement possesses multiple arguments, this column will be divided accordingly.
Documentation: This is a read-only column providing comments elucidating the statement in an understandable manner.
Furthermore, there are two additional columns, Assignment and Comment, which can be integrated into the Keyword view by selecting Tools -> View Options and opting for the required columns from the list.
Assignment: This column is responsible for assigning or receiving values from variables, but its utilization is rather limited.
Comments: This column enables the tester to append comments which will be treated as comments in the expert view.
Wrapping Up
This wraps up our discussion about the essential features of the QTP Keyword View. Actions offer a logical separation of tasks within a test. Tests are a sequence of function calls. By default, all actions are reusable. QTP follows a multi-tiered hierarchy for object recognition. An object containing other objects is referred to as a container. Grouping objects enhances manageability and readability.
In our forthcoming article, we will discuss how to insert steps, edit them, incorporate checkpoints and breakpoints, and manage actions using the Keyword view.
=> Navigate Here For The QTP Training Tutorials Series
This is the second entry in our QTP training series, crafted with the aid of QTP expert Swati Seela. These tutorials are designed keeping both novices and advanced QTP testers in mind. Stay tuned with every single post in this series by opting for our email newsletter or subscribing to our RSS feed. This will be the most comprehensive QTP online training available to everyone.
As usual, we encourage you to propagate this valuable testing resource by sharing it on your social media platforms. If you seek clarity on this topic, don’t hesitate to question us in the comments section below.
If you’ve read this far, you should surely follow us on Twitter: Follow @VijayShinde