QTP Tutorial #5 – Moving Steps and Dealing with Breakpoints


QTP training tutorial #5 – moving steps, deleting steps and dealing with breakpoints in keyword view. This is the fourth and the last article on QTP keyword view features.

If you missed any article in this QTP training series please check all articles on this page: QTP Training Tutorials

Other features of the Keyword View:

We are almost approaching the end of sessions concerning the ‘Keyword View’ of QTP. How it looks, what it does, what can we do with it – These are some of the aspects we are trying to unveil in the course of our articles. Understanding the view, adding steps, conditional statements are already dealt with.

Today we’ll learn remaining Keyword View features such as moving steps, deleting steps and dealing with breakpoints.

Just like always, we will use the sample test we have been working with – The login operation on the Flight sample application.

Moving steps:

1) The first and the simplest way – Keyword view acts like any text modification application when it comes to cutting, copying and pasting the steps. Thus, all the clipboard shortcuts are applicable.

  • Ctrl+C – Copying
  • Ctrl+V – Moving
  • Ctrl+X- Cut

2) The next way is by choosing the menu option. To use this, select the step that needs to be moved and choose the following menu choices:

  • Edit->Cut
  • Edit->Copy
  • Edit->Paste

3) The other method is dragging and dropping.

Any of the above methods can be used to move steps. However, there are few ground rules:

  1. The loop or condition statements can only be moved in blocks. For example, for an ‘if…else’ statement you cannot just move the else part.
  2. In a step, where the item is a child object and the user decides to move it, there is one of the two scenarios that come up. Either the step gets moved under the same parent or to a different parent. If it is moved under the same parent, it simply comes up in the new position chosen. But if it is moved under a different parent, the parent gets duplicated. Let’s see this pictorially:

[Note – click on any image to enlarge]

Moving steps in QTP

I am going to move the step where we enter the agent name (the one highlighted above) under the ‘Flight Reservation’ parent object. Let’s note that the parent object for ‘Agent Name’ is Login. I simply dragged the step to be the last one. This is how, it appears:

Moving steps by dragging in QTP

Earlier in the introduction sessions, we have discussed that we can have multiple actions in a test. Let us see how a test with multiple actions would appear in the keyword view and how this view can be used these actions as desired.

To achieve this is, I am simply going to convert all the steps under the parent object ‘Flight Reservation’ in our above example to appear under another action. Adding actions, steps to actions all these are going to be discussed in detail as we move on in our sessions.

Action 1:

Moving steps in QTP action 1

Action2:

Moving steps in QTP action 2

As you can notice in the test flow pane, the sequence in which these actions are executed is displayed.

QTP test flow pane

If I would want the Action 2 to run first followed by Action 1, keyword view let’s me do that by allowing me to drag and drop the actions to the necessary position.

With this, we have covered all the information necessary to move steps/actions/blocks within a test using the keyword view.

Delete Steps:

Deleting steps from QTP could not have been simpler. All you need to do is choose the step that you do not want in the test and simply hit the “Delete” button on the keyboard or right click on  a step and select “Delete” from the menu or select a step and choose “Edit->Delete” from the main menu.

If a step that has sub-steps defined for it is chosen for deletion, the following message is displayed to the user:

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

QTP delete steps

What this means is that, if a step with sub-steps is chosen for deletion, all the sub-steps get deleted too.

And, that’s all there is to discuss about deleting steps.

Adding Breakpoints to the test from the keyword view:

Often, during the execution there might be one or more things that you want to key an eye out for and observe what kind of changes are happening. This might be to see the state an Object gets to or to note a value a variable takes etc. A facility that helps us do just that is a Breakpoint. It is basically a certain point in your test where you want to pause the test run and observe or obtain certain information about your test. Most times this feature makes debugging easier.

Now, that we know what a breakpoint is, we will try to understand how to add them to our tests from the keyword view.

All you need to do is, click in the left margin at the particular step where you need to pause the test. The addition of a breakpoint is represented by a red dot in the left margin corresponding to the step where a break is added.

Here is how it looks:

Adding breakpoints in QTP

Selecting a step and pressing F9 on the keyboard also results in the addition of a breakpoint.

Insert remove breakpoint

Lastly, the menu option “Debug->Insert/Remove Breakpoint” can also be used.

So, once a breakpoint gets inserted, the test will run until the step where it is inserted normally and will come to a halt before executing it. At the point the tester can perform the required observations for which the program was stopped and continue to run it by choosing the “Run” option one more time from the main menu whenever he is ready.

If we add a breakpoint from the keyword view, the same is displayed in the Expert view also in front of the line corresponding to the row to which it gets added.

Breakpoints in expert view

The vice versa is true too, if you add a breakpoint from the Expert view, it gets reflected in the keyword view.

As simple as it is to insert a breakpoint it is even simpler to delete is once its purpose is served or when it is no longer needed.

Delete Breakpoints

Clicking one more time on the line where the breakpoint already exists will result in its deletion. Keyword F9 or the menu option “Debug->Insert or Delete Breakpoint” can be chosen on a step with a breakpoint and it gets removed.

Conclusion:

So this concludes the discussion of all the properties and capabilities of keyword view in detail. This view is the most readable one among the two and once all the features are understood, we can use it as effectively as possible to make the tests robust.

The coming QTP tutorial will deal with how to record a new test and what are the factors that determine the success of a being able to do so.


The Best Software Testing Training You'll Ever Get!

software testing QA training

17 comments ↓

#1 Kartik on 03.06.13 at 8:50 pm

is it possible to save breakpoints in test? open the script having breakpoints. does it load previously created breakpoints?

#2 Leslie Sam on 03.06.13 at 9:06 pm

great stuff. thank you

#3 Swati Seela on 03.07.13 at 7:39 am

@Kartik: No, it does not load the previously created breakpoints

#4 Devanshu Lavaniya on 03.07.13 at 8:33 am

Really sorry to say but Article is Not up to the mark
i am disappointed :(

#5 PO on 03.07.13 at 9:43 am

Really great stuff.

Request for you, can you please make series of tutorial for Selenium IDE, Selenium RC and Selenium Gridsame like this ? It will be more helpful who is looking opensource alternative for QTP.

Thanks in Advance :)

#6 Swati on 03.07.13 at 9:13 pm

@ Devanshu Lavaniya: Sorry. What expectations of yours did we not meet in this article? Please let us know…we will work on making it better

#7 ade on 03.08.13 at 5:51 pm

I need information on doing the Scrum Master exam and i need some help with past questions and answers and the best book to buy..
Please contact me on dickieponga@yahoo.co.uk

#8 slava on 03.12.13 at 9:11 am

More!))

#9 CKR on 03.12.13 at 4:58 pm

Hi Guys,
I have 2 years of experience and its been 4 months since i left because of family matter which is completely resolved now, can anyone suggest me in finding a job with 4-5 months of career gap…???

#10 CKR on 03.12.13 at 5:03 pm

currently I am staying in Bangalore

#11 Senthil on 03.13.13 at 8:49 pm

I have doubts in the following point 1.The loop or condition statements can only be moved in blocks. For example, for an ‘if…else’ statement you cannot just move the else part
Doubt # 1: If i copy the else part alone of the if else statement , the if part alone is copied and pasted Doubt 2#: Any statement inside a condition statement/loop can be copied and pasted seperately . It is not getting copied as a block.

#12 Swati on 03.16.13 at 4:55 pm

@Senthil: The moving in blocks is more to establish a integrity of a block statement. It is to make a logical sense. In case you copy one without the other it usually does not have its meaning. I hope that helps…

#13 Shantosh on 03.20.13 at 6:40 am

Very good article about QTP.. waiting for chapter 6 when it will be available

#14 Senthil on 03.20.13 at 4:36 pm

@Swathi : Thank You Swathi .. awaiting your next series of tutorials

#15 Pradeep on 05.04.13 at 2:13 pm

Hi Swathi,

Your tutorial’s from 1-5 are written in a nice way with screen shots. I’ve gone through quite a few websites on QTP automation,but for a beginner, i would say your tutorial is the best.Thanks.

#16 Medha on 08.28.13 at 2:14 pm

V Nice Article… surely helpful…. Kp us updated with such kind of Knowledge …

#17 venkat on 02.15.14 at 9:24 am

I have a doubt.. Consider we have multiple Actions say Action 1, Action 2 and Action 3.Now I want to Execute the Action 2 alone, with out executing Action 1 & 3.how ti achive it

Leave a Comment