Monday, June 13

Utility Statements in QTP - Part 3

Hello Friends,
This is in continuation from Part-1 and Part-2 of posts. Here we will cover following utility statements-
GetLastError Statement
InvokeApplication Statement
Print Statement
RegisterUserFunc Statement
RunAction Statement
SetLastError Statement
UnregisterUserFunc Statement
Wait Statement

GetLastError Statement

GetLastError returns the error code of the last/most recent error. It is used with the DescribeResult Statement.

Browser("mybrowser").Page("mypage").Image("myimage").Click 23, 47
errX = GetLastError
print (DescribeResult(errX))

In the above example, the script fails because the Login image was not found on the page. The error number is retrieved Using the GetLastError function and description of error using DescribeResult Statement.

SetLastError Statement

Inserts a VBScript error into the test script.


InvokeApplication Statement

InvokeApplication is used to invoke an executable application i.e. '.exe' files.

InvokeApplication "C:\Program Files\Internet Explorer\IEXPLORE.EXE"

Print Statement

Print is very useful and simple to use statement, generally used in place of 'msgbox'. It displays information in the QuickTest Print Log window during the

run session. The log window remains open until you close it manually.

Print "This is an example"
Print Browser("MyBro").GetROProperty("title")

RegisterUserFunc Statement

Using RegisterUserFunc, you can add a new method or can override the existing method of any test object class.

For example, 'Set' is a method of WebEdit class, which sets value in the edit box.

Using RegisterUserFunc, you can change the behaviour of this method or you can add new method to WebEdit class.


Function NewSet (obj, val)
 Dim MyWord
 MyWord = UCase(val)   ' Returns val in upper case
End Function

RegisterUserFunc "WebEdit", "Set", "NewSet"
Browser("MyBro").Page("MyPage").WebEdit("name").Set "abhikansh"
UnRegisterUserFunc "WebEdit", "Set"

In above code, you have just overridden 'Set' method with your new function 'NewSet'. Now default behavior of the Set is changed. Whatever you type now, it will be written in upper case in the edit box.

Enables you to add new methods to test objects or change the behavior of an existing test object method during a run session.

When you use this statement, QuickTest uses your user-defined function as a method of a specified test object class for the remainder of a run session, or until you unregister the method.

If the specified method name does not already exist for the test object, it becomes a new method for the object. If the method name is a defined QuickTest method for the object, your definition (temporarily) overrides the existing functionality of the specified method.

Please note that..

1. Registered method applies only to the test or library file in which you register it.
2. It is applicable to current run session only.
3. QuickTest clears all function registrations at the beginning of each run session.
4. UnRegisterUserFunc instructs QuickTests to stop using the current registration of the method.

RunAction statement

The RunAction statement runs the specified action (if associated with your test).
If you want to run external action, which is not associated with your test, then you have to use (Insert > Call to Action) or (Insert > Copy of Action) options from QTP menu.

RunAction "Action2", oneIteration

Easiest and more accurate way to use RunAction is through Menu.

Wait Statement

Wait is one of the most commonly used utility statement. Used for a pause of specified seconds, during a run session.


Above statement will cause a pause of 10 seconds before moving to the next steps. Its a method of synchronization.

For other Synchronization methods, please refer >>


  1. Thank you very for share us such kind of good info

  2. Crypto-currency as a modern form of the digital asset has received a worldwide acclaim for easy and faster financial transactions and its awareness among people have allowed them to take more interest in the field thus opening up new and advanced ways of making payments. Referral Code with the growing demand of this global phenomenon more,new traders and business owners are now willing to invest in this currency platform despite its fluctuating prices however it is quite difficult to choose the best one when the market is full. In the list of crypto-currencies bit-coins is one of the oldest and more popular Referral Code for the last few years. It is basically used for trading goods and services and has become the part of the so-called computerized block-chain system allowing anyone to use it thus increasing the craze among the public, Referral Code.

    Common people who are willing to purchase BTC can use an online wallet system for buying them safely in exchange of cash or credit cards and in a comfortable way from the thousands of BTC foundations around the world and keep them as assets for the future. Due to its popularity, many corporate investors are now accepting them as cross-border payments and the rise is unstoppable. With the advent of the internet and mobile devices,information gathering has become quite easy as a result the BTC financial transactions are accessible and its price is set in accordance with people’s choice and preferences thus leading to a profitable investment with Referral Code. Recent surveys have also proved that instability is good for BTC exchange as if there is instability and political unrest in the country due to which banks suffer then investing in BTC can surely be a better option. Again bit-coin transaction fees are pretty cheaper and a more convenient technology for making contracts thus attracting the crowd. The BTC can also be converted into different fiat currencies and is used for trading of securities, for land titles, document stamping, public rewards and vice versa.

    Another advanced block-chain project is Ethereumor the ETH which has served much more than just a digital form of crypto-currency Referral Code and its popularity in the last few decades have allowed billions of people to hold wallets for them. With the ease of the online world,the ETH have allowed the retailers and business organizations to accept them for trading purposes, therefore, can serve as the future of the financial system.

  3. Health Experts have proven that regular exercise coupled with a good diet allow you to live longer and healthier. In this busy day and age, not everyone has the time to go to the gym - resulting to a lot of overweight people that desperately need to exercise. A healthy alternative is for you to Buy Home Gym Equipments that you can store in your own home or even at your office. Here are some tips when buying home gym equipment.

    First, know your fitness goals and keep these goals in mind when you are buying home gym equipment. One of the biggest mistakes that people make is buying the biggest or trendiest fitness machine simply because they like how it looks. More often than not, these end up gathering dust in your storage rooms or garage because you never end up using them. It is important to take note of what particular type of physical activity you want or enjoy doing before you buy your exercise machine. If you are looking to loose a few pounds and you enjoy walking or hiking, a treadmill is the best option for you. If you are looking to tone your lower body while burning calories a stationary bike is your obvious choice. Similarly, Special Equipments for Core Strength Exercises, Strength Training Weight Vests, Core Strength & Abdominal Trainers, Home Cardio Training, Strength Training Power Cages, Strength Training Racks & More.

    Second, set aside a budget before Buying Home Gym Equipments. Quality exercise machines do not come cheap. They are constantly exposed to wear and tear when they are used properly. So, pick machines that are built to last and have passed quality certifications to get the most out of your money. If you are operating on a tight budget, think about investing in several weights, We can Provide you High Quality Home Gym Equipments at Very Low Prices for your Complete Uses: Core Strength Exercises, Strength Training Weight Vests, Core Strength & Abdominal Trainers, Home Cardio Training, Strength Training Power Cages, Strength Training Racks & More.

    Its the Right Time to Buy Home Gym Equipments for you at Very Low Prices.