Debug a test, component, function library, or user code file

Relevant for: GUI actions, scripted GUI components, function libraries, user code files, and business process tests

This task describes different ways you can control and debug your run sessions so you can identify and handle problems in your documents.

To practice this task, see Debug a function - Exercise (for GUI testing) orDebug an API user code file - Exercise (for API testing).

Prerequisites

  • You must have the Microsoft Script Debugger installed to run tests or components in debug mode. If it is not installed, you can use the UFT Additional Installation Requirements Utility to install it. (Select Start > All Programs > HPE Software > HPE Unified Functional Testing > Tools > Additional Installation Requirements or <UFT installation folder>\bin\UFTInstallReqs.exe.)

  • To debug API tests, you must enable the debugger. Select Tools > Options > API Testing tab > General node and select Run test in debugging mode.

Back to top

Slow your debugging session

During a run session, UFT normally runs steps quickly. To slow the test run speed to enable more effective debugging, in the Test Runs pane of the Options dialog box (Tools > Options > GUI Testing tab > Test Runs node), specify the time (in milliseconds) UFT pauses between each step by modifying the Delay each step execution by option.

Back to top

Step into, out of, or over a specific step

Step Into In the toolbar, press the Step Into button .
Step Out In the toolbar, press the Step Out button .
Step Over In the toolbar, press the Step Over button .

Back to top

Start or pause at a specific step or action

  • Select the step in your document at which you want UFT to stop and select Run > Run to Step.

  • Select the step at which you want UFT to start the run and select Run > Debug from Step.

  • Note: These commands can also be used to stop at a specific action. Right-click an action in the canvas and select Run to Action, Debug from Step, or Run from Action.

Back to top

Use breakpoints

For details, see Use breakpoints .

Note:  

  • If you a run a test using the Run automation method, the test does not stop at breakpoints even if they are saved in the test.
  • If you run a test with breakpoints using the Run automation method, the breakpoints remain visible but are ignored during the test run.
  • If you are running a test from the ALM Test Lab module in hidden mode (as specified in the UFT Remote Agent, UFT will not stop the test at the breakpoints.
  • If you are running a test from the ALM Test Plan module not in hidden mode, the test stops at breakpoints if you select the Run Test Sets in debug mode option in the UFT Remote Agent

For details on Remote Agent settings, see Remote Agent Settings Dialog Box.

Back to top

Check the values of variables and expressions

In the Watch Pane

The Watch pane displays the value of selected variables and expressions that have been added to the Watch Pane.

To add an expression do one of the following:

  • Click the Add New Watch Expression button and enter the name of the expression in the Add New Watch dialog box.

  • For GUI actions, scripted GUI components, and function libraries only: Highlight the selected expression and select Run > Add to Watch right-click the expression and select Add to Watch from the context menu.

To add an to the Watch pane, you must use an expression that calls GetROProperty. This enables you to watch the run-time value of the object's . For example, to watch the value currently displayed in the Calculator application, you can add the expression:

Window("Calculator").WinEdit("Edit").GetROPRoperty("text")

You can add an expression to the Watch pane from the Editor or from a function library, but not from the Keyword View.

In the Quick Watch
  1. In the line in your test or component containing the object, variable, or expression, do one of the following:

    • Right-click and select Quick Watch

    • Select Run > Quick Watch

  2. In the Quick Watch, do one of the following:

    • In the Expression field, enter the name of the object, variable, or expression and click Evaluate. UFT displays the value in the current context of the test or component.

    • Enter the name of the object, variable, or expression and click Add to Watch. UFT adds it to the list in the Watch Pane

In the Local Variables pane UFT displays all variables in the test or component (up to the current step) and their value in the current context of the test or component run.
In the Editor

Hover over an object, variable, or expression when the test run is paused. UFT displays a floating tooltip with the value:

Note: To expand the ability of UFT to display information on test objects, we recommend registering PDM from Internet Explorer (for versions of Internet Explorer 8 or higher and Visual Studio 2008). Enter the following in the command line to register the .dll: regsvr32 "%ProgramFiles%\Internet Explorer\pdm.dll"

Back to top

Modify the values of variables or expressions

Do one of the following:

  • In the Console pane, enter a command to change the value of an object, variable, or expression.

  • In the Watch or Local Variables pane, in the Value column for the object, variable, or expression, manually change the value.

  • Back to top

Manually run code commands

In the Console pane, enter the command to run.

Back to top

View the current call stacks

To view the currently running call stacks in your run session, select View > Debug > Call Stack. You can double-click on a stack name in the pane to navigate directly to the line of code that begins the call stack.

Back to top

View currently running threads

Select View > Debug > Threads. In the list of threads that is displayed, you can double-click on the thread name to navigate directly to the beginning of the thread.

Back to top

View the loaded modules

Select View > Debug > Loaded Modules. UFT displays the list of currently loaded modules (depending where in the test you have paused).

Back to top