Timeouts and Error Handling

As everyone who uses a browser knows, things frequently don't go how you expect. Web sites go down, connections fail, systems and computers experience problems. You might be wondering, how can I make my scripts run reliably in the face of all this unreliability? One way that you can manage the unreliable world is by using Timeouts and Error Handlers.

  • Timeouts ensure that items in your script do not take excessive amounts of time and ensure that if things go wrong your script keeps running and returns a result to you.
  • Error Handlers allow you to retry or abort items that fail automatically.

Timeouts and Error Handlers can be configured on any playable item, including requests, navigations, and even Steps. If you configure a timeout for a Step the timeout will govern the whole Step so that the sum of the times for all the items in the Step will be limited to the timeout period.

Configuring a Timeout

To add a timeout, simply open the properties for the item on which you would like to configure the timeout and choose the "Playing" tab:

Click Item

Once a timeout is configured, Badboy will monitor the item as it plays and if the time you set is exceeded, Badboy will execute the Continuation action you specified.

Notes and Limitations
  • Some items cannot be timed out during certain phases of their execution due to their nature. For example, once the Save item has started writing data to the disk it will continue even if a timeout occurs. When the save finishes the timeout will execute.


  • Timeouts have a minimum resolution of 1 second. This means that the actual timeout may occur at plus or minus one second from when you configure it to occur. For low timeouts this may be a significant effect and thus it is not recommended to configure timeouts for less than 2 seconds.

Error Handlers

Errors include problems like server failures, HTTP protocol errors (for example, 404 Not Found), or network failures. By default, when an error occurs, Badboy will simply note the error and continue playing the next item in the script. You can change this behavior by configuring handling for errors on the Playing tab of the item, or on a parent of the item such as the Step or Test that it resides in.

The figure below shows how the error handling section of the properties dialog appears:

Click Item

To make Badboy completely ignore an error, you can enter a regular expression pattern ("regex") that matches the URL for which the error occurs, or which matches the error message that is reported by Badboy. You only need to match a portion of the error for the match to succeed.

To make Badboy ignore all errors on an item, enter the regex pattern: .*

To configure other handling for errors, change the "Action on Error" drop down box to specify the action you would like. For example, you can make Badboy abort the current Test if an error occurs, or repeat the containing Step. A particularly useful option is "Retry this item". The Retry option removes the error response and re-executes the item on which Retry is set one time before registering the error. For example, you can set a Retry on a Step and if any item fails inside the Step then Badboy will clear the error and try the Step again. If there is no error on the second try then the script will continue without reporting any problem. However if the item fails again on the second execution then Badboy registers the error. This can help you prevent transient or temporary problems from causing your tests to fail in situations where Badboy is running on unreliable networks or is subject to other occasional problems.

Continuation after an Error or Timeout

When you configure handling for errors or timeouts, you have the option to control what action is taken when the timeout occurs. These include:

Timeout ActionsDescription
Continue from same positionAborts the currently playing item and continues with the next item.
Abort this StepAborts the currently playing Step and continues with the item following that Step in the script.
Abort HierarchyAborts the whole hierarchy of Steps right to the top level. Continues from the next item in the script following the top level Step containing the item that timed out.
Stop PlayingStops the play sequence altogether. Badboy will stop and wait for manual intervention.
Repeat Containing StepRewinds back to the Step containing the item that timed out and plays the Step again. Note that any loop counters will be reset so that the Step will re-execute its looping behavior as well.
Retry this itemDiscards any error response in the item and replays it one time only. If playback fails a second time, record the error and continue playing.


Badboy Documentation Generated on Thu Dec 31 12:56:46 EST 2009