Saturday, May 3, 2014

QTP / UFT 12.0 - RunDebug

QTP / UFT 12.0 - RunDebug

Definition of RunDebug
RunDebug runs the test in the debug mode, meaning that the test stops at all the breakpoints which are inserted in the test.

Syntax of RunDebug:
Object.RunDebug [ResultsOptions], [WaitOnReturn], [Parameters]

1. ResultsOptions is Optional: A RunResultsOptions (A collection of properties that indicate preferences for the run results.) object.
2. WaitOnReturn is Optional: A Boolean value.
3. Parameters is Optional: A Parameters (A collection of Parameter objects. ) object.

A very simple example of RunDebug:
Launch QTP / UFT 12.0.
Open a new test.
Write the below code (Descriptive Programming code) in the new test:
(This below code runs fine for me. Make sure it runs fine for you also or else make the modifications so as to run it.)
SystemUtil.Run "C://Program Files/Internet Explorer/IEXPLORE.EXE"
Browser("title:=about:blank").Navigate ""
Browser("title:=Google").Page("title:=Google").WebEdit("name:=q").Set "qtp"
Browser("title:=qtp - Google Search").Page("title:=qtp - Google Search").Sync
Browser("title:=qtp - Google Search").CloseAllTabs
The above code opens IE, navigates to Google and searches for word "qtp" and then closes the browser.

Create a new .vbs file (I created "a.vbs"). Write the below code in it and save it.
Dim qtApp
Dim qtTest
Set qtApp = CreateObject("QuickTest.Application")
Set qtTest = qtApp.Test
Set qtTest = Nothing

Make sure QTP / UFT 12.0 with the new test (we created above) is open.
Go to command prompt and run the "a.vbs" file. This will run the test open in QTP / UFT 12.0 at present.

Now insert a new breakpoint at line 4 in QTP:

Run "a.vbs". This will run the test open in QTP / UFT 12.0, observe that the script will not pause the test at breakpoint.
Now change the "qtTest.Run" line in script to "qtTest.RunDebug" and run it again. You will observe that now with "qtTest.RunDebug", the scripts stops at the breakpoint.

If you try to run the same above steps (i.e. RunDebug) with QTP / UFT 11.50, you will get the below error: