HTML Forms are the core of many modern web applications. Form Populators help you populate and submit forms as part of your Badboy scripts.
You often don't have to use Form Populators at all - Badboy automatically records and sends the data from the Forms as Request parameters, so it typically isn't necessary to actually populate the form on the page. There are some times, however, when certain visual or functional effects are explicitly linked to the population of a form. Form Populators are here to help you when you need to test these kinds of pages.Some examples are:
A new Form Populator added to your script appears as shown below:

Once a Form Populator has been created, you need to add the fields that you would like populated to it. There are several ways to do this. The easiest is to let Badboy do the work by capturing the form automatically. You can do this very simply in a couple of ways:
The Figure below shows how the Form Populator properties dialog appears:

In order to use the Capture button, you should first choose the form that you would like to populate from by selecting either it's index (ie. the position of the form based on the order the forms appear on the screen), or its name. If you aren't sure which form to populate from then the easiest method is to simple try capturing different indexes until the element you want appears. It is often useful to use the DOM View to help select the correct form. When you have selected the form you would like to populate from, just hit the Capture button and Badboy will capture form elements along with their current values from the form that you selected.
Occasionally you may need to populate a form whose name is not the same each time it appears in the page, but follows a fixed pattern. For example, in some applications the form may have a constant name followed by a number that changes. For these cases you can enable the "Use Regex" option and enter a Regular Expression that matches the pattern of the of the form you wish to populate. For example, if the form is always called "logonForm" followed by a 4 digit number, you can use an expression like this:
logonForm[0-9]{4}
Sometimes Badboy may automatically record Form Populators for you. This occurs when you record a Navigation (see Navigation Items) and you have modified some fields in a form on the page that you are recording. In this case, Badboy detects the modified fields and creates a Form Populator for those fields so that when you play back they fields will be populated correctly.
Form Populators are easy to play - the behave the same way as other Badboy elements and can be played either using the right-click menu or as part of the normal flow of your script. You should be aware that if the form that you attempt to populate does not exist on the page, Badboy will generate a warning in the log file, but will continue playing without error. If you want to be assured that the form populated correctly, you may like to use an Assertion.
Form Populators work by recording the values present in forms as "Form Values" that are children of the Form Populator in the script. When a Form Populator is played, each of its child Form Values is populated into the form. If you want to change which values are populated by a Form Populator, you can do that by modifying the Form Values by editing their properties.
As well as a name for the field, each Form Value has an "index". Indexed Form Values are used when there are multiple elements in a form that have the same name or id. When this occurs, Badboy will record a form value for each form field that has the same name and an index that specifies which instance of the field having that name should be populated.
Selection boxes present a minor complication in form population because each entry in the dropdown menu is in fact represented by two different values that are both useful in populating them on playback:
By default Badboy records the first of these options - the value submitted to the server, and on playback it selects the option in the select box that has that same submitted value. This often works well but in some cases it may fail or be more difficult to use. For example, if the page uses arbitrary values for the options that change each time the script is played back then playback will not work because the original recorded value may be incorrect next time the script is played back, even though the text of the option values stays the same. It may be also may easier to select the option based on the displayed value when you are doing data driven testing such as loading the values from a spread sheet or other external source where the codes are not externally known but the text values are.
For these cases where the human readable value is more appropriate, open the Form Value properties and select the option "Match Visible Text for Select / Dropdown Fields". This will change playback to select the option where the text displayed in the dropdown matches the script Form Value rather than the code submitted to the server.
If you wish, Badboy can also submit the populated form after it has populated it. This allows you to use Form Populators as an alternative to the usual Request and Navigation Mode playback mechanisms. Used in this way, Form Populators can often assist to automate operations that experience problems using other methods.