During the script debugging, there often arises a need to look at the current values of the variables used in the script.
In this recipe we will deal with several methods of doing this.
In order to familiarize ourselves with the lookup possibility of the variable values, we will need to write a small script with the use of different variable types.
function testDebug1() { var pNotepad = Sys.Process("notepad"); var num = 15.8; var str = "string value"; var bool = true; Log.Message("Dummy message"); }
Log.Message
method call takes place (set the cursor on the line and press F9 button).pNotepad
variable and click on OK. The variable will show up in the list of those being tracked.num
, str
, bool
, and so on).As a result, all the variables will appear on the list. One can also look up their values and types there (if TestComplete can determine the value for the given variable type).
To the Watch List list we can add any variables and even entire expressions for the lookup of their current values. For example, if we enter num+str
as an expression, the values of the same will be tantamount to 15.8 string value, since TestComplete will automatically transmute the number to the string and join two string-type expressions together.
If we are working with the objects (pNotepad
, in our instance), we can also look up their values via the uncollapsed view of the tree of the sibling objects, as shown in the previous screenshot.
Values on Watch List are updated automatically, and this is why usage of the list is especially handy when using loops, when it's required to track the variable value at each iteration.
For quick lookup of the values of a given variable, it is not necessary to add it to Watch List, as it's enough to hover the mouse cursor over the name of the variable at any place of the script and TestComplete will show the tool tip with the value of the variable at hand.
Another method to quickly view the values of the variables is the Locals
listing, in which all the local variables are shown (that is, the variables from the current function). The Locals
list can be found on the same panel where Watch List is located.
18.191.144.194