Home
About Us
Advertise
Contact Us
Email
Search:    
Welcome to the Exciting World of Software Testing
 
Get the Latest Posts Delivered to You
Through E-mail
 
 
 
Download Consolidated Study Material for Certification Exams Like
 
 

Tips to Optimize HP QTP 11.0 Scripts to Yield Better Performance

Facebook share
Delicious Bookmark this on Delicious
Welcome to “Software Testing Genius”. Subscribe to my RSS feed for latest content on Software Testing.

Tips to Optimize HP QTP 11.0 Scripts to Yield Better Performance

We use Automated-testing tools to optimize our manual testing processes. But in order to reap full benefits of any automated testing tool, we must know the complete ins and outs of the tool otherwise it would be a huge waste of money spent on automation. We have to learn the automation tool very thoroughly. We also need to learn the language of the automation tool to do coding more effectively and efficiently. I believe that a software testing tool is as good as the person who is actually using it.

I have been getting so many emails from my esteemed readers asking about HP QuickTest Professional tutorials, QTP tips and tricks etc. Some readers even complain that their QTP scripts are too slow to execute. This time I decided to write a post on how to use QTP more effectively which means how to make our QTP scripts perform better. In order words, this post will throw light on some points, which will optimize your QTP scripts.

Some of the QTP optimization tips can be:

Tip – 1: You should not use hard coded wait statement until absolutely necessary. Instead of the wait statement, you should use either exist or synchronization (sync) statements. The wait statement waits for the number of seconds, which have been provided. For example using wait(5) will wait for 5 seconds even if the browser gets into a ready state even after 2 seconds which means a waste of 3 seconds. Imagine how much time would be wasted if you have say 10 wait statements per script and you are running a batch of 500 scripts. A better alternative is using sync or exist statements for example:

Browser("").Page("").Sync

var=Browser("").Page("").Exist(2)

Never use the exist statement without a value as it will take the default object synchronization timeout value from QTP settings. You can navigate to these settings from File->Settings and then go to Run tab. So use Exist(0) instead of Exist(10). Moreover, I will suggest to set the global object synchronization timeout to 1 second.

Tip – 2: Use declared variables instead of using variables on the fly. In order to enforce this in your scripts, use Option Explicit statement which forces the variable declaration. Moreover, using declared variables, scripts perform a bit faster. Also if you are using Option Explicit, it has to be the very first line of the code otherwise you will get an error.

Tip – 3: Using QTP for a longer period of time has a direct impact on the performance. It has been observed that a lot of Random Access Memory(RAM) gets consumed by QTP if QTP is running scripts for prolonged time. QTP starts eating system memory(memory leak) and sooner or later it will get hanged and we will be required to kill the qtpro.exe process and restart QTP all over again. In such a case, I will suggest you is to use QTP on computers with particular good amount of RAM and equally good clock speed.

Tip – 4: Do not load all addins while opening QTP. Use only the addins, which are required. This directly impacts QTP performance.

Tip – 5: I have personally experienced that opening QTP through a vbs file is faster than loading QTP through the icon.

Tip – 6: Switch to fast run mode. You can view this option in Tools->Options->Run. In fast mode, QuickTest Professional does not display the execution marker. In case you are running your scripts from Quality Center or QC, by default they will be run through fast mode.

Tip – 7: Disable the Smart identification feature.

Tip – 8: Switch off the video record option unless required as it will require fewer system resources. You can see this Option in QTP by navigating here Tools->Options->Run.

Tip – 9: Use of Active screen feature should be avoided, so that we increase QTP Tool performance.

Tip – 10: Instead of keeping the entire code in the same script, try to increase modularity by creating reusable components (Actions or functions) so that the code size can be reduced and also easier to maintain. To disable Action screen in QTP 11, go to Tools->Options->Active Screen and set the capture level to "None".

Tip – 11: Destroy the objects when you no longer need them. As objects take up relatively large amount of system resources, it is better to destroy them when you don’t need them anymore.

For example, refer the following code:

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objRootFolder = objFSO.GetFolder("C:\")

Set objFSO = Nothing

Msgbox "The folder was last modified on :"& objRootFolder.DateLastModified

Set objRootFolder=Nothing

Notice from the above code that we need objFSO code just to retrieve the handle of "C" folder. As soon as you get the handle, you no longer need the objFSO folder. So instead of destroying this object reference at the last line, you should destroy when you don’t need the object reference anymore. You should follow the principle of limiting object lifetime as much as possible.

Tip – 12: Creating an object reference increases the performance. For example, refer the following QTP code:

oEdit = Browser("Google").Page("Google").WebEdit("q")

oEdit.Set "Optimize QTP Scripts"

'The above code is definitely better in terms of performance than using the QTP code:

Browser("Google").Page("Google").WebEdit("q").Set "Optimize QTP Scripts"

You will not see major performance difference in this two liner code. To see a noticeable difference, you need to have hundreds of lines of QTP where you will see the difference. The reason is setting an object reference reduces the call to the Object repository.

Tip – 13: I have also seen that using With statement in HP QTP increases performance but only upto a very small extent. In order to add With statement from QTP IDE, navigate to Tools->Options->General tab and select the option "Automatically Generate "With" statements after recording" option.

Tip – 14: Having too many objects in the Object repository/shared object repository slows down the QTP scripts. So the best option is to have only the desired objects in the Object Repository.

Tip – 15: Use local variables in functions rather than using global variables. The best practice is to limit the scope of a variable as much as possible.

Tip – 16: Try to make sure that your QTP code does not wait for events, which have already been executed. For example see the below QTP code:

iTimer = Timer
objWindow.Close
  Do
    If Dialog("micclass:=Dialog").Exist(0) Then _
        Dialog("micclass:=Dialog").Type MicEsc
  Loop Until (Not objWindow.Exist) Or (Timer-iTimer>20)

Instead of having a loop which will wait for 20 seconds for an event to occur, you should have a loop similar to the above. This loop will continue to loop until either of the condition is met: Either the timer has crossed 20 seconds or the window no longer exists.

I hope the above article has touched lot many QTP optimization tips. I don't claim to be an expert on QTP, however I have made an attempt to share the above tips based upon my experience with this great tool. Please feel free to add some points in the comment section if I happen to miss any. I will be glad to update this article giving appropriate credit to the people.

Like this article? If yes!!! Then please share it with your friends & colleagues on facebook and LinkedIn to promote your favorite website so that it reaches more audience.

More Articles on HP QuickTest Professional 11.0 


Facebook share
Download Full Study Material for ISTQB - Foundation & All 3 Advanced Level Certification Exams

What Successful Testers say about the Quality of this Website

If you want to keep track of further articles on Software Testing, I suggest you to subscribe my RSS feed.

You can also Subscribe by E-mail
and get All New articles delivered directly to your Inbox.

Full Study Material for Popular Certification Exams:

Study Material - HP QTP & QC Certification Exam

Study Material - HP LoadRunner Certification Exam

Study Material - IBM RFT Certification Exam

Consolidated Study Material - Testing & QA


Most Popular Topics in Demand:

Practical Roadmap to QTP Certification

Practical Roadmap to ISTQB Certification

Practical Roadmap to CSTE Certification

General HR Interview Questions Common For All 

Tricky HR Interview Questions Common For All
 

Rehearsal of QTP in 1 Hr. -  Interview Questions

 

Comments :

9 comments ↓

# 1 Dmitry on 2012-01-27 07:56:28
Another great article from QTP expert Yogindernath. I didnt know that you are so good in QTP also. This article is well worth reading.


# 2 Lomas Gupta on 2012-01-27 16:24:21
I always switch off the smart identification feature as I dont think its reliable. Overall all the above points are very helpful.

I have shared this article on facebook and linkedIn.

Regards,
Lomas


# 3 Chris Nicholls on 2012-01-27 17:09:24
Hi,

I am facing an issue with QTP Object spy. I have pressed CTRL+Left mouse button together and I am trying to select the Internet explorer window which is not the active window. How to do this?


# 4 Yogindernath on 2012-01-27 19:09:45
Hi Chris,

This is a limitation with QTP on Windows XP. Using Object spy, you can not select taskbar items after pressing CTRL+Left Mouse button.

As a workaround, use CTRL+Right mouse button to open the shortcut menu and select the option "Restore". This way you can activate any window.

I hope I am able to clear your QTP doubt.

Regards,
Yogindernath


# 5 Roger on 2012-01-28 08:49:56
Is there any QTP patch that will help me recording against Firefox 9? Its very urgent. Please help me ASAP


# 6 Shireen on 2012-01-31 16:26:04
Hi everyone,

I am looking for the best automation testing tool for .NET and WPF based applications. Can anyone suggest me which tool I should go for?


# 7 Robinsh on 2012-02-01 00:02:34
Not tech savvy but your article was also clear to me and I also understood a little what you were talking about.


# 8 vinay on 2012-02-02 01:12:06
Realy an Expert Opinion............its awesome....good
Article


# 9 Yoginder Nath on 2012-02-05 18:09:00
This text is bold, underlined. Also contains simelys :-) :-))



Leave Your Comments: (*) Marked Fields are Mandatory

You can apply basic formatting to the text

Name *
 
Email Address *
 
Website
 
Speak your mind
characters
  Subscribe
 
Sign up to receive daily updates
either via email or RSS!
   
Please use Vertical Scroll Bar
to View More Categories
 
 
     
 
 
advertise | privacy policy | copyright policy | online conduct home | about us | glossary | contact us | blog | email
Copyright © 2011. softwaretestinggenius.com. All Rights Reserved.
Powered By: Cyberframe