Debug Scripts

This topic describes different options to debug a TruClient script.

View replay Errors in the TruClient Development window

If any steps failed during replay, they are marked with an error icon. 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

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

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.

Global Watch Panel

During replay, use breakpoints to inspect the values of variables in the Global Watch panel.

  1. Define variables in a Evaluate JS step.

    For example:

    var str = 'TruClient';
    var obj = {name:'TruClient',
        version:{
        major:12,
        minor:50
      }
    }       
    			
    var arr = [1, 2, 3];
  2. Enter a breakpoint in your script.
  3. When you replay the script, the Global Watch panel appears. The 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 Global Watch panel. This will generally only be necessary if automatic display of variables is disabled.


Back to top

Debug scripts using snapshots

TruClient generates snapshots during recording 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. Record snapshots are stored in the snapshot folder.

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

  1. Select the General Settings button on the Development Window 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 at recording time. 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.

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 Toolbox and perform a click or mouseover action on the list.

Steps are displayed in the user interface only if they will be 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 screenshot 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.

Back to top

Handling short events

Sometimes event replay is too short. For example, there might be a mouseover that opens a dropdown menu or listbox. The object must be open before an option is selected. During replay, the list closes when the mouseover 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 mouseover step end event to "Action Completed".
  • Remove both the mouseover 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:

  • A Wait step delays the next step for the specified time.
  • A Wait for Object step delays the next step until the specified object is loaded.

To insert a Wait Step, select Toolbox > Functions and drag the Wait or Wait for Object icon to the desired location in your script. If you add a Wait step, configure the interval in the argument section of the step. If you add a Wait for Object step, select the Click to choose an object button to select the target object in the application.

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

Note: Wait Steps differ from Think Time steps in other Virtual User Generator 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.

For more information on Firebug Lite, see TruClient Browser for Internet Explorer.

Back to top

Resolving 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

General tips for successful interactive replay

  • Do not switch between applications during interactive replay. Keep the browser in focus.

  • Do not re-size the browser between record and replay and during replay. This can cause objects to move and interfere with TruClient's ability to locate them.

    This is especially important when the Related Objects feature is used, as resizing may change the relative position of the objects.

  • Any customizations (such as bookmarks) that you make within this instance of the browser will not be saved for general use. This is because TruClient opens each script in a unique browser profile. We recommend that you open a browser outside the TruClient context for your normal use.

  • When using TruClient Lite, do not open another instance of the same type of browser you are using to record. For example, if you are recording on Chrome and you want to browse at the same time, open Internet Explorer, Firefox, or any browser other than Chrome.

  • When using TruClient Lite, you can select which browser (Firefox, Internet Explorer, or Chrome) is used for cloud replay. This is not used by TruClient Lite itself (which can only run on Chrome), but is used to replay scripts running in the cloud, such as for StormRunner Load.

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:

Best practices

  • 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).

Tips to improve performance

Configure the following replay and debug settings in Interactive Options:

Tip: You can also use TruClient Coded to help resolve these issues.

Back to top

See also: