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

Relevant for: API testing, 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) or Debug an API user code file - Exercise (for API testing).

Prerequisites

Ensure that you have the following prerequisites before you start debugging:

Microsoft Script Debugger

You must have the Microsoft Script Debugger installed to run tests or components in debug mode.

If it is not installed, use the UFT One Additional Installation Requirements Utility to install it:

  • Select Start > All Programs > Micro Focus > Micro Focus UFT One > Tools > Additional Installation Requirements
  • Browse to <UFT One installation folder>\bin\UFTInstallReqs.exe
Enable the API test debugger

To debug API tests, you must enable the debugger.

Select Tools > Options > API Testing tab > General node and then select Run test in debugging mode.

Back to top

Slow your debugging session

During a run session, UFT One normally runs steps quickly. When debugging, you may want to slow the test run speed to enable more effective debugging.

To slow the test run speed:

  1. Browse to the Test Runs pane of the Options dialog box (Tools > Options > GUI Testing tab > Test Runs node).
  2. Modify the Delay each step execution by value with the number of milliseconds you want UFT One to wait between each step.

Back to top

Step into, out of, or over a specific GUI step

Use the following methods when debugging a GUI test to determine how your steps are run.

Step Into

Runs only the current step in the active document.

In the toolbar, press the Step Into button .

When debugging a GUI test, if the current step calls another action or a function, the called action or function is displayed in the document pane. The test or function library pauses at the first line of the called action or function.

Step Out

Continues the run to the end of the function, or user code file, returns to the calling test, component, or function library, and then pauses the run session at the next line (if one exists).

In the toolbar, press the Step Out button .

Step Over

If the current step calls a user-defined function, the called function is executed in its entirety, but the called function script is not displayed in the document pane. The run session then returns to the calling document and pauses at the next step (if one exists).

In the toolbar, press the Step Over button .

If the current step calls another action, the called action is displayed in the document pane, and the run session pauses at the first line of the called action (like Step Into).

Back to top

Start or pause at a specific GUI step or action

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

  • Select the step at which you want UFT One 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 in GUI tests

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 One Remote Agent, UFT One 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 One Remote Agent

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

Back to top

Check the values of GUI testing variables and expressions

During a run session, use the following options to view the current values of code expressions, variables, and object properties.

As you continue stepping through the subsequent steps in your test, function library, or user code file, UFT One automatically updates the Watch pane and Local Variables pane with the current value for any variable or expression whose value changes.

UFT One also reevaluates the information displayed in the Watch pane and Local Variables pane as you make changes in the context of your debug session (in the Console Pane).

Back to top

Change GUI testing properties, variables, or expressions

Change the value of a variable or property manually in Watch pane and Local Variables pane.

For example, for test objects that support the Object property, edit the value of a run-time object property displayed in the Watch pane, thereby changing the value of the property in the application you are testing before you resume the run session.

Do one of the following:

Console pane Enter a command to change the value of an object, variable, or expression
Watch or Local Variables pane In the Value column for the object, variable, or expression, manually change the value
Watch pane or Quick Watch

Add any of the following types of expressions:

  • The name of a GUI test object

  • The name of a variable

  • The name of a property

  • Any other type of code expression

Expressions added to the Watch pane are saved with the document and updated accordingly as you make changes to your document.

Caution: UFT One runs the expressions in the Watch pane to evaluate them.

Therefore, do not add a method or any expression whose evaluation could affect the state of the test or any GUI test object. This can lead to unexpected behavior of your test, component, function library, or user code file.

Manually run GUI testing code commands

In the Console pane, enter the command to run.

Back to top

View the current GUI testing call stacks

To view the currently running call stacks in your run session, select View > Debug > Call Stack.

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 GUI testing 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 GUI testing modules

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

Back to top

Disable API test steps

Disable a step in an API test to skip it when you run and debug the test.

In your test, right-click the step you want to disable and select Disable step. The step is disabled and will be skipped when you run your test to debug it.

When you are ready to enable the step again, right-click the step and select Enable step.

When steps are disabled:

Event handlers

Event handlers attached to the step are also skipped.

Steps with values used as data sources for other steps

If the skipped step has input values that are used as data sources in other steps, default values are used instead.

Steps linked to checkpoint values

If the skipped step is linked to a checkpoint value, the test run will fail because of a missing value.

Back to top