Debug a TruClient script

This topic describes different options to debug a TruClient script.

View replay errors

If any steps failed during replay, they are marked with an error icon in the TruClient Development window. Hover the mouse over these icons to view descriptions of the errors.

Back to top

Run the script step by step

You can run your script step by step to view the replay more slowly and in a controlled manner. To run the script step by step, select the down arrow from the replay button in the browser and select Replay step by step. Repeat this procedure after each step to continue the step by step replay.

Back to top

View the replay logs

TruClient maintains log files that record various operations that were performed when running a script in interactive and load mode. These log files may be useful when debugging a TruClient script.

You can view details of your script's replay in the VuGen Output Pane. Select Output Pane > <Browser name> - Interactive Replay.

TruClient log files are stored in the TruClient script folder:

interactive_replay_<Browser type>.txt

Log file that records various operations that were performed when running a script in interactive mode.

Example: interactive_replay_TruClientBrowser.txt


Log file that records various operations that were performed when running a script in load mode.

Back to top

Insert toggle breakpoints

Breakpoints instruct the script to stop running during a replay when in interactive mode. They can be used to help debug your script.

To insert a toggle breakpoint, right-click the desired step and select Toggle Breakpoint, or click to the left of the step number. A breakpoint is indicated by to the left of the step number.

Inspector Panel

During replay, use breakpoints to inspect the values of variables in the Inspector Panel.

  1. Define variables in an Evaluate JavaScript step. For details, see Add steps to a script.

    For example:

    var str = 'TruClient';
    var obj = {name:'TruClient',
    var arr = [1, 2, 3];
  2. Enter a breakpoint in your script.

  3. When you replay the script, the Inspector Panel is displayed. The Inspector Panel displays all parameters and user-defined variables. You can disable the automatic display of variables in General settings > Interactive options > Debug.

  4. To display the value of a variable at the breakpoint, enter the name of the variable and click the + to add it to the Inspector Panel. In general, this is only necessary if automatic display of variables is disabled.

Text visualizer

When you hover the cursor over a variable value, the variable code is displayed in a popup window. You can display variable values in a more meaningful way by using the text visualizer.

  1. Click the arrow that is displayed to the right of a variable name in the Value column.

  2. The Text Visualizer window opens displaying the entire string of the variable value.

  3. Use the text wrap option as required to avoid having to scroll across the entire screen for long text.

    Clear the Wrap option, for example, to facilitate the use of line numbering (scroll to the right to see the ends of long lines).

Back to top

Debug scripts using snapshots

TruClient generates snapshots according to the snapshot generation settings. These snapshots can be viewed by hovering the mouse over each step's icon. The snapshots are taken before the step's action is implemented and they are saved as .png files. Click each snapshot to display it in a new browser tab. Make sure that the correct tab is active before replay.

You can use the snapshots generated during replay to debug scripts by viewing the snapshots of the failed step(s).

  1. Click the General Settings button on the Development window menu toolbar and select the Interactive Options tab. Set the Replay Snapshots Generation to On Error.

  2. Replay the script from the Development window.

  3. To view the snapshots from the Development window, select a step with an error, and select the button.

You now have a group of snapshots that displays the errors that occurred during replay.

For UI details, see Snapshots.

Back to top

Modify and view script and step levels

TruClient filters steps during replay by their level. Each step is assigned a level number between 1-3 at recording time (the level is displayed in the step ). Lower numbers represent higher levels.

  • Level 1 steps are necessary to the business process. Failing to execute them may cause subsequent steps to fail.
  • Level 2 steps affect the application in a way that is probably not important to the business process.
  • Level 3 steps have no apparent effect on the application.

For example, a click step is assigned level 2 if it occurs in an area of the application that has no effect.

Modifying the step level

When replaying a script, the replay itself is set to a level from 1 to 3. If the script replay level is 1, then only level 1 steps are replayed, if the script replay level is 2 then level 1 and level 2 steps are replayed. If the script replay level is three, then all recorded steps are replayed. You can modify the script level to include more or less steps, or you can raise or lower the level of a step so that it is included or excluded at the level at which you replay. By default, scripts are replayed at level 1.

Sometimes you must override TruClient's step level assignment. For example, mouseover steps are generally assigned level 3, since many mouseover steps are recorded simply by the user moving the mouse around the screen and few of the steps affect the application state. However, if a mouseover opens a list and enables clicking an option, clicking an option fails if the mouseover is not replayed first. In this case, lower the script level to 3 to display all steps, open the required step and click the step section. Since this mouseover is necessary, move the step level slider to level 1. If the step is part of a group step, both the group step and the individual step must be modified. Return the script level slider to its previous position.

If the necessary mouseover was not recorded at all, add a Generic Object Action from the Steps box and perform a click or mouseover action on the list.

Steps are displayed in the user interface only if they are executed at the current script level. Lowering the script level to 2 or 3 makes more steps visible. The numbering of steps always reflects all of the recorded steps. The following screen shot displays a small script. Note that the step numbers skip from 1 to 3. Step 2 is hidden in a different level.

After changing the display settings by using the slide bar, all steps are now displayed and will run if replayed in interactive mode.

Automatic leveling during replay

The level of a step is normally set during recording. If the level is set too low, the replay may fail, for example, generating an “object not found” error. During replay, TruClient checks if there are steps at a level lower than the current script replay level that can affect the outcome of the current step. If found, the meaningful step is moved to a higher level.

Filtering steps at the script level

You control the steps that are displayed in the Development window from the Script Level dropdown in the menu bar:

  • Select to display level 1 steps only (highest level).
  • Select to display level 1 and 2 steps.
  • Select to display all steps.

Back to top

Handling short events

Sometimes event replay is too short. For example, there might be a mouse over that opens a dropdown menu or list box. The object must be open before an option is selected. During replay, the list closes when the mouse over event ends. The following click on an option fails because the list is not open. There are two ways to handle this situation:

  • Change the Mouse Over step end event to Action Completed.
  • Remove both the Mouse Over and the Click steps, and replace them with an Evaluate JavaScript step which performs both actions in the same step.

Back to top

Insert Wait steps

Sometimes a script fails to replay because an object required by a step is not available immediately after the End Event of the previous step. You can resolve this by inserting Wait Steps to ensure that the next step does not start until the wait condition is true. There are two types of Wait Steps:

Type Description To insert a Wait step
Wait Delays the next step for the specified time.
  1. Click Step, select Functions and drag the Wait step to the desired location in your script.

  2. Configure the interval in the argument section of the step

Wait for Object

Delays the next step until:

  • The specified object is loaded. This is the default setting (the argument value is set to true).

  • The object does not exist. If the object exists when the step executes, the step waits until the object disappears, or the object times out (the first event). If the object does not exist when the step executes, the step ends.
  1. Click Step, select Functions and drag the Wait for Object step to the desired location in your script.

  2. Select Choose an object, and select the target object in the application.

  3. To delay the step until the object does not exist, in the Arguments section of the step, set the Exists values to false.

You can run a script without the wait steps by selecting the Ignore wait steps option on the Interactive Options tab of the Configure TruClient General Settings.

Note: Wait Steps differ from Think Time steps in other VuGen protocols. Think time is the time the script waits between actions to emulate user reaction time. Wait Steps pause a script replay until a condition is met.

In a Wait step, set the Think Time argument true to include the wait time in the think time calculation.

Back to top

Debugging plug-ins

To further improve debugging capabilities, you can install plug-ins such as DOM Inspector and Firebug that can provide additional information on the application object properties.

Back to top

Resolve step timeouts

Steps may time out for several reasons:

  • The application is responding slowly, possibly under load. This is actually an important test result and indicates a performance issue.

  • Step Timeout is incorrect and should be modified in the Step section of the step properties.

  • The end event of the step is incorrect and the step is waiting for an event that does not occur. The end event should be changed in the Step section of the step properties.

Back to top

Resolve object identification issues

If an error is discovered during replay, you can highlight the object that failed, and TruClient automatically recognizes the selected step. For details, see Object identification.

You can also use the Descriptor Editor to improve or control object identification in your TruClient scripts by adding or editing conditions. For details, see Descriptors.

Back to top

Tips for working with large scripts

When working with large scripts (those with a few hundred steps), it can be difficult to edit the script because of the time it takes to add, delete, locate, or replay selected steps.

To minimize or avoid these issues, we recommend following these guidelines:

  • Divide the script logic into multiple actions and functions, where each action does not have more than 50 steps.

  • Give meaningful names to actions and functions.

  • Add comments in the script to help you find specific parts in the script more easily when using the Find dialog box (Ctrl + Alt + F).

Back to top

See also: