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.
Example – Call Stack in UFT
Let’s consider it through the following example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Call dispNumb(20,30) 'Calling dispNumb Function dispNumb(ByVal x,ByVal y) x = addNumb(x,y) 'Calling addNumb function inside dispNumb msgbox "Value of x is " & x & " and value of y is: " & y End Function Function addNumb(Byval a,Byval b) addNumb=multNumb(a,b)+b 'Calling multNumb function inside addNumb End Function Function multNumb(Byval a,Byval b) multNumb = a*b End Function |
- 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.
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.
1 2 3 4 5 |
a = 25 b = 30 c = a+b Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").Set "TestUser1" Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("Sign-In").Click |
1 |
Print Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("userName").GetRoProperty("value") |
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.
1 |
Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").WebEdit("html tag:=INPUT","type:=password").Set "abcd@12" |
It will set the password in the password field.
Recommended Posts
- How to Use Data Driver for Automated Parameterization in UFT
- How to Use RegisterUserFunc in UFT with Examples
- How to Use Insight Object in UFT
- How to Open Multiple Tests in UFT
- Actions in UFT One with Examples
- How to Use Shell Scripting in UFT to SendKeys
- How to Use Recovery Scenario in UFT with Example
- Delete Browser Cookie, Cache, and History in UFT
- Import Excel File into Datatable in UFT