QTP Tutorial #3 – Adding Standard Steps From Keyword View

This is a tutorial #3 in our QTP Training series. Check out the first two QTP tutorial in this training series here: QuickTest Professional (QTP) tutorials

Adding Standard Steps From Keyword View

In last tutorial we saw how to work with keyword view.

Today’s article is going to be about adding steps to a QTP test from the keyword view. Before we go about adding the steps, let’s see what kind of steps we can add at all:

  1. Standard Step: A standard step is anything that acts on an object. For example, a set operation on an edit box with a particular value or selecting a value from a list box.
  2. Checkpoint Step: Checkpoint is a step in a QTP Test that compares an expected value of a specific property/state of an object with the actual value. This is a kind of validation that QTP provides to the users to make sure their AUT is working as intended. So, when this kind of a step is inserted, QTP performs a check during this step execution and if expected and actual values are same, the checkpoint passes or else it fails. An example of a checkpoint is, if in an application a checkbox is supposed to be ON after its selected or a particular name that a text on the screen should be, etc. QTP has 10 checkpoints that it provides the users with. Apart from these, the tester can verify and validate any conditions by programmatically writing them. All the check points will be dealt in detail in the coming articles.
  3. Output value: As the name implies an output value is nothing but a variable that stores the outcome of a particular step in a test. This value can be used subsequently as an input for another step. This value is only available for the time period of a test run after which it gets reset. This topic also will be detailed out shortly.
  4. Comments: Any step that is a non-programmatic and won’t be executed, but is put in the script to increase readability is a comment.
  5. Conditional and Loop statement.
  6. Other: These are the kind of statements that help in designing the programming logic. Some examples are sync statement, writing into test results etc.

Let’s start with adding a standard step. For our convenience I am going to explain the use of only item, operation, value and documentation columns in the keyword view. Though there are two more columns, they are seldom used.

Inserting a step is the first part of adding a line to a program. A step merely adds a blank line in your test. It is up to the tester to define the step and to add details to the step. The details include what item to act on, what operation to perform, what value to assign etc. If it’s a new test, any step we are trying to add becomes the first step. From the menu main, select Insert-> New Step after clicking anywhere in the keyword view.

[Note - click on any image to enlarge]

Add new step in QTP keyword view

Another way is to right click on an existing step and selecting Insert new step from the menu.

Add new step in QTP keyword view 2

Both of these option result in the addition of a new line after the selected step. If a container object was selected while adding a new line, the new step gets added as a sub-step. If a last-level object was selected, the new line gets added as a sibling.

Here is how the new line looks like. The new line added is nothing but a skeleton that can be defined as required.

Add new step view

So, the first thing you see in a newly inserted line is a ‘Select an item’ drop down.

Newly inserted line in keyword view

Given the fact that everything operation needs an object to be performed on, this is inevitable. Now as we already discussed item can be anything, a Test object, Statement, Utility Object or comment. The Test objects that are contained under a Container Object are displayed here. Therefore, according to our example, Agent Name, OK, Password is displayed in the list when a new step is to be added while clicking on or under the sub-level steps of the Login Dialog.

Object Repository:

If anything other than the items listed are required by the user there is an option to select the same from Object Repository. Now, this is the first time in our articles that we have encountered the word Object Repository. So, what is it really? When we try to put it simply, an Object Repository is what its name suggests. It a place or more like a database where all the Objects in a test are stored. This is what happens when the user chooses ‘Object Repository’ from the list.

------------

Object Repository view in QTP

So either from the list displayed or from Object repository an item can be selected. The next thing is to define the operation to be performed on the selected object. Click in the Operation column and a list of operations that can be performed on the selected object are displayed. This list is dependent on the type of object selected. For instance, a dialog object will have different methods available than when an Edit box is chosen.

Choose the desired operation

Select object in keyword view

The next column is the Value. As we already know that this column is the argument to the operation to be performed on the selected item. On clicking in this column, the arguments are displayed as shown below:

Argument value

If more than one argument is required to carry out the said operation, all the arguments will be displayed as multiple cells in the Value column.

The type operation on the ‘FlyFrom’ item needs a keyboard input. When the icon in this column is displayed the following dialog is displayed that helps the user to configure this value.

As you can see from the window above, the value to be entered in this field can either be a ‘Constant’ in which case the constant value can simply be typed in the text box and then followed by clicking the ‘OK’ button in the window.

Or it could be parameterized, which means it would be picked up from a location in the data sheet, a random number or an Environment variable. How to parameterize a value for an argument will be discussed in length later on.

Value configuration option

In our example, I am writing “Test” in the constant field and clicking OK and here is how the line generated looks:

Argument value 1

It should be noted that the ‘Documentation’ field gets auto-populated with the description pertaining to the operation performed on the item selected.

Conclusion

So, that concludes the topic, ‘Adding a standard step to a test from the Keyword View’. We have discussed the various kinds of steps that can be added from the Keyword view and explored the adding of a Standard Step in detail.

We’ll have couple of more articles on QTP keyword view. In the coming articles, we will see how to add the other kinds of steps, adding conditional and loop statements and how the Keyword view can be used to modify/delete the test steps.

*****

We need your feedback to improve this QTP training article series. Let’s make it more interactive. Add your questions in below comments. Join our email newsletter as there are many more articles to come in this series.

Believe us this will be the most comprehensive QTP training article series you’ve ever seen online!



The Best Software Testing Training You'll Ever Get!

software testing QA training

15 comments ↓

#1 Ajay Mehtre on 03.03.13 at 8:32 pm

can you tell us all checkpoints we can insert using keyword view?

#2 Sunita K. on 03.03.13 at 9:33 pm

thank you vijay and swati for these useful QTP articles.
I am learning qtp 11 currently and also need some qtp interview questions to prepare side by side while learning.

#3 Vinod on 03.04.13 at 4:30 am

Thanks buddy..
Awesome tutorial.

#4 Manidipta on 03.04.13 at 5:22 am

Hi, Thanks for the Notes. Can we have a session on QTP Actions/Action Call.

Thanks.

#5 Swati Seela on 03.05.13 at 2:56 am

@Ajay Mehtre: Checkpoints is coming up as an independent article. You will find the details soon….

#6 Swati Seela on 03.05.13 at 2:56 am

@Manidipta: Sure, Actions is also an independent topic coming up…

#7 Anil kumar M R on 03.06.13 at 10:34 am

From my little knowledge , we will working more with Expert view rather than Keyword view. Keyword view is rarely used. Am I correct or wrong. can any one clarify

#8 Hitesh on 03.06.13 at 11:37 am

@Anil: You are right anil but due to initial phase of training, we should have at least an idea about keyword view, What you say?

#9 Swati Seela on 03.07.13 at 7:42 am

@Anil Kumar M R: QTP has two views. Each one has its own capabilities. So it is really upto the user to decide which to use depending on the comfort and also the test at hand. Since this is a tutorial on the entire QTP Tool, we would like to give as much information as possible…I hope this helps.

#10 neelima on 06.11.13 at 5:23 pm

which version of QTP are u using in these tutorials?

#11 saurabh shekhar on 06.14.13 at 12:18 pm

I liked your tutorial very much.. Thanks a tone !!

#12 p on 06.26.13 at 1:07 pm

It’s god if you can explain indetail more, thanks.

#13 Uthra Umesh on 07.27.13 at 4:04 pm

Is there any difference when we select an item from the Object Repository and when we select an item from the dropdown for a new step?

Because in both cases we can select only the item corresponding to the particular container object under which the step was added.

#14 Laxmikant Borde on 07.31.13 at 5:33 am

Good!! Thanks

#15 sudhakar on 12.12.13 at 6:45 pm

good.. u r doing the great job!

Leave a Comment