How to Use Call Stack in UFT to Trace Function Calls with Example

Call Stack in UFT is used to trace nested function calls. It is used while debugging a Test, where a stack trace in UFT helps automation testers to figure out where a problem lies in the code or how various subroutines and functions work together during execution.

call stack in uft

Example – Call Stack in UFT

Let’s consider it through the following example.

I have written the following three functions.
  • dispNumb
  • addNumb
  • multNumb

The dispNumb function is calling the addNumb function which in turn calls the multNumb function. Add a breakpoint inside the multNumb function as shown below and run the Test.


When the script pauses, go to View>Debug> Call Stack.


The Call Stack pane will be displayed.

call stack in uft example

The stack trace reads from the bottom up that is why the multNumb method would be displayed at top of the stack as it is the current function that is being called. By looking at the Call Stack you can easily figure out the flow of the execution path and how landed up inside a function.

Console in UFT

The Console pane in UFT is a very useful debugging tool. If you are debugging a Test and the script is paused at a breakpoint you can do the following things.

  • Getting information from the AUT(application under test)
  • Set or modify the value of variables
  • Performing an action on an object(The object must be in the object repository or use descriptive programming)
  • Use Print, Msgbox, and other test methods at runtime

Let’s try to understand the aforementioned things with the help of simple examples.


I have assigned some values to three different variables a,b and c. After that the I am setting the username to the Mercury demo application and clicking the Sign-In button. Here the catchy thing is that I am not setting any value to the password field. I will do that, later on, using descriptive programming.
I have set two break points in the script as shown below and running the Test.
The script will pause at line 3. Now go to View>Debug> Console. The Console Pane will be displayed at the bottom of the UFT window with a command line as shown below highlighted with yellow color. You can type a valid command over here.
In the command line, I am updating the value of b. Initially, the value of b is 30. I am reassigning a new value 50 to it by typing the command b=50. Press enter after entering the command.
Hit F10 and enter command msgbox c in the command line and press the Enter key.
A message box would be displayed with the value 75 as we have modified the value of variable b from 30 to 50 and c=a+b.
Now open the Mercury Tours Demo application by opening the URL and record and run settings keep the option “Record and run on any open browser”.Press F10.UFT will set the value for the username.
Now we will try to retrieve the value of the username from the application using the GetRoProperty method and display the same in the Output pane using the Print command.


The output will be displayed in the Output pane.


Now the run pointer is at line 5 that is supposed to click the Sign-In button. But we haven’t entered the password. We will set the password in the password field using descriptive programming and writing this in the UFT command line field. Write the following code and press the Enter key.


It will set the password in the password field.


At any point, you can clear the commands entered in the Console pane. Do a right-click and select the “Clear All” option.

Recommended Posts

Leave a Reply