Automating your Scripts

Being able to replay back a sequence of browsing activities repeatedly can be a very useful mechanism for debugging and testing your web site. Unfortunately, playing back exactly the same requests that were used on a previous occasion frequently does not satisfy the requirements of complex web sites.

Some examples of scenarios where this can occur are:

· An identifier that is entered must be unique. Entering the same value twice generates an error. This would occur, for example, if you tried to make a script that would register for an account with a user Id. The first time it ran it would succeed, but on replay trying to sign up for the same Id again would generate an error

· You recorded the script on one server (for example, your local development box), but you would like to run it against a different server. You need a way to replace the host name to which the requests are directed.

Badboy helps you deal with these problems in several ways. These are Editing Parameters, Script Variables, and a variety of tools to help you such as Search and Replace. Read on to find out more about these!

Editing Parameters and Hosts

Badboy allows you to edit the values of request parameters and host names in your script. This is very easy to do - just double click on the request or parameter that you would like to change the value of.

Using this feature you can find and change any values that need to be updated before you run your script.

Searching and Replacing

If you have a value that you need to change throughout your script then finding and editing every occurrence of that value would be very long and tedious process. To help with this, Badboy has a Search and Replace feature. You can invoke the Search and Replace function by selecting "Search/Replace" from the Badboy's Edit menu. Alternatively you can just press "F3" to show the dialog. The figure below shows the search/replace dialog:

Search Replace Dialog

Property Mask

Sometimes when searching and replacing you only want to search for specific properties of an item, such as it's name, id, or other property. If you want to filter the properties that are considered in the search, specify the name of the property to match on in the Mask field. Note that you can use a regular expression in this field to match multiple properties or a range of properties matching a particular pattern.

After you have opened the search dialog with F3 and entered your text, pressing F3 again will search for the text. You can keep pressing F3 to find the next item containing your text.

Variables

If you have values that change often you will quickly get tired of having to search and replace in your script. To alleviate this Badboy provides a feature called “script variables”. Script variables are displayed in the "Variables Tab" (usually in the bottom left corner of the Badboy window) and contain values that you can reference by name throughout your script. This allows you to include references to variables in your parameter names and host names by using the syntax "${variable name}" to include a variable value. In this way you can create scripts that share the same value in many places and you can maintain it in just one place.

To add a variable, just right click on an item in the tree on the item that you would like to become controlled by the variable, and choose "Add Variable". To edit a variable's value, just double click on the variable in the Variable View and changes its value in the properties box..

Linking Values

Often the same parameter value is sent many times in a script. Badboy offers a feature called "linking" to help you find all the places where it the value is occurs and replace them with variables. Linking automatically joins all the separate instances of a recurring value to a single variable. If you use a linked variable, you only have to create the variable once and from then on all the items in your script with the same value will be converted to use the variable. To do this, simply add a variable by right clicking on a parameter in the script and choose "Add Linked Variable". After adding the variable, Badboy will search for all values that are the same as the one you selected and change their values to reference the new variable. Linking is especially useful because Badboy will also automatically replace values for new items that you add or record in your script with variable references whenever or however they appear. This way you don't need to remember to add variable references as you work with your script.

Badboy has a special tool to help you link a variable to host names in your script. This is very useful if you would like to test your script against a different host to the one you recorded on. To do this, just choose "Create Hostname Variable..." from the Tools menu in Badboy's main window.

Using the Date/Dime to Create Unique Parameter Values

Using Variables you can create scripts that can be easily run repeatedly to test a defect, validate code as you write it, or a myriad of other uses. It is a very common occurrence, however, to need variables that are guaranteed to be unique each time the script is played. The scenario of creating a user account is a good example. To help with this, Badboy makes it easy to automatically set variable values to a unique value. You can do this by adding an Increment script item (available in the Toolbox) at the start of your script. You can place increments into your script wherever you want new values for your Variable. Increments have many other abilities and features - for more information on Increments, see the topic Incrementing Variables.

There are many more advanced uses of variables to automate your scripts. To learn more, see the following sections:


Badboy Documentation Generated on Mon Dec 29 22:28:41 EST 2008