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. Oferecemos os melhores serviços para seguidores, curtidas, comentários e visualizações no Instagram. Os serviços são entregues de forma rápida, segura e por um preço honesto e barato.
    Todos os serviços são iniciados de forma automática e você pode fazer um teste grátis de seguidores, curtidas e visualizações no Instagram.

    O Go Followers surgiu em 2015 e durante alguns anos foi o melhor e maior site para comprar seguidores, curtidas e comentários no instagram. Com o passar dos anos evoluímos e em 2021 lançamos um novo site simples e intuitivo para aumentar a experiência dos mais de 150.000 clientes atendidos.

    Nossa ferramenta envia seguidores brasileiros reais e ativos em sua grande maioria para qualquer perfil do Instagram. Escolha o melhor pacote para comprar seguidores instagram de alta qualidade. Você poderá escolher alguns pacotes como seguidores com curtidas, seguidores masculinos, seguidores femininos e seguidores automáticos.
    Todos os pedidos são feitos de forma automática e iniciam em poucos minutos após a compra, tá esperando o que?

  3. PG SLOT มีเกมหลากหลายให ้เลือก พรอ้ มกราฟฟิกแอนนเิมชนั่ สวยงามทสี่ ดุ ในยคุ นี้แจ็คพอตแตกง่าย pgslot โปรโมชนั่ พเิศษส าหรับทงั้สมาชก เกา่ และสมาชกิ ใหม่ ระบบฝาก-ถอนเงินออโต ้เงินเข ้าเร็วทันใจมีแอดมิ ดูแลตลอด 24 ชวั่ โมง ต ้องที่ มั่นคงจ่ายจริง ไม่ว่าคุณจะถอนเงิ มากมายเท่าไหร่ ทางเว็บจ่ายเต็มไม่มีหัก pgslot ปั่นง่ายแตกง่าย

    pg slot ผู ้ให ้บริการเว็บตรง ที่แตกง่ายที่สุด ปั่นสนุก ฝากเงินรับเครดิตฟร สูงสุด 15000 บาท สมัคร พีจีสล็อต หรือ PGSLOT กับเราเพื่อความมั่นคงของคุณเอง.

  4. forum posting refers to generating quality incoming links by taking part in online discussion forums. It permits you to post new posts and reply to previous ones to drive traffic to your web site.

  5. 메이저놀이터리스트 안전메이저놀이터 메이저놀이터추천 pattern that give you money Part2

  6. Secret mansion 스포츠중계 — like something out of James Bond

  7. Prosecutor explains dice-sliding scheme at Cleveland 온라인포커 바둑이게임

  8. The Dollop: The Epic Failed Robbery of Harvey's 바카라게임사이트 예스카지노 & Big John Burgess