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. The Additional Installation Requirements program is available from the Windows Start menu or by running <UFT_One_installdir>\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. |
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:
- Browse to the Test Runs pane of the Options dialog box (Tools > Options > GUI Testing tab > Test Runs node).
- Modify the Delay each step execution by value with the number of milliseconds you want UFT One to wait between each step.
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). |
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.
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.
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.
The Watch pane displays the value of selected variables and expressions that have been added to the Watch Pane.
Note: Hidden properties and methods of test objects are not displayed in the Watch Pane.
Add an expression to the Watch pane from the Editor or from a function library, but not from the Keyword View.
To add an expression do one of the following:
Enter the expression name | Click the Add New Watch Expression button and enter the name of the expression in the Add New Watch dialog box. |
Highlight a selected expression |
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 a description property 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 property. For example, to watch the value currently displayed in the Calculator application, you can add the expression:
Window("Calculator").WinEdit("Edit").GetROPRoperty("text")
For details, see Watch pane.
UFT One's Quick Watch enables you to view the current value of a selected object in a line in your test or component, evaluate the value of an expression, or add an item to the Watch Pane.
-
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
-
-
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 One 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 One adds it to the list in the Watch Pane.
-
In the Local Variables pane, UFT One 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.
For details, see Local Variables pane.
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).
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:
|
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.
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.
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.
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).
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. |