Evaluating expressions

Most often, to look up the variables' values in the debugging mode, it is enough to resort to the Watch List and Locals possibilities. For more complex tasks, we can use the Evaluate window.

Getting ready

Create the following function:

function testEvaluate()
{
  var pEx = Sys.Process("explorer");
  Log.Message("");
}

and set the breakpoint on the second line of the function (set the cursor on this line and press F9).

How to do it...

To get acquainted with the possibilities of the Evaluate window, we will need to implement the following actions:

  1. Launch the created testEvaluate function. Its execution will be stopped and TestComplete will switch to the debugging mode.
  2. Navigate to Debug | Evaluate or press the following combination of keys: Ctrl + F12. In the result, the Evaluate window will appear on the screen.
  3. Input pEx into the Expression field and click on the Evaluate button. In the result, the Result field will get the current value of the pEx variable ([Object]) inputted.
    How to do it...
  4. If we click on the Inspect button, the screen would have the Inspect window displayed, which is analogous to that of Object Browser, where all the properties and methods are viewable.
  5. Close the Inspect window and input the "string value" string (by all means, with the quotation marks!) into the New value field and press Enter.

    In the result, the string value line will show up in the Result field. Now, the pEx variable contains a new value.

How it works...

The Evaluate window extends wider possibilities of working with various expressions as compared to that of the Watch List list:

  • The first major difference consists in the possibility of assigning the variables with the new values, while the variables' types can be altogether different (for example, in our case, the variable of pEx first contained the object, and then the line).
  • The second difference consists in the Inspect window. In this sense, it resembles Object Browser; however, we can use it to look up not only the sibling objects of the Sys element, but rather any other objects as well. For example, it is possible to enter the BuiltIn value into the Expression field and look up all the properties and methods of the BuiltIn object, which are extended by TestComplete.

Also, from the Evaluate window, one can add a current expression to the Watch List list (with the help of Add Watch) for further tracking.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.140.196.244