Browsers are intimately mouse driven tools, so it is not surprising that there are times when nothing other than a real mouse click will replay exactly the effect you are looking for in a test. Some common examples of situations when this can happen are:
In all these situations a simple and effective solution can be to control the browser by automating mouse clicks in the window. Fortunately, Badboy makes recording and adding Mouse Clicks easy.
Adding a Mouse ClickTo add a mouse click, just drag a Click Item from the Toolbox into your Script. The figure below shows how a Click Item appears in the script:

When you add a Click Item, the properties dialog box for the Click Item will show giving a number of options that you can choose to determine how the mouse click is performed. The following paragraphs describe these. The figure below shows how this looks:

These parameters determine the window and the location within the window (in pixels) where the mouse click will occur. The mouse click is always relative to the top left corner of the window specified. This means that you don't need to worry about where the window appears on the screen (which can easily change), but only about where in that window the click needs to occur. Note that sometimes looks can be deceiving - some applications use many layers of windows and consequently if you enter the numbers manually you may have to experiment to get the right X and Y position. Sometimes you may even find that the values you need are negative. The best way to set all these parameters at once is to use the Capture Button (see below).
Capturing the Click from an Existing WindowBy far the easiest way to create a Click Item is to capture it from an existing window on your screen. This means that you should set up Badboy (and any other windows you expect to be on the screen and open the Click Item properties and then click the Capture button. The next left click that you do will then be captured, including window title, X and Y position. Note that you are not limited to recording clicks inside Badboy's browser window - you can record clicks on any window on your desktop, even Badboy's menus or the desktop itself!
Tip:Badboy offers a shortcut way to create Mouse Click Items: just click (anywhere) in a browser window that you want the click to occur in, position the mouse at the right location and the hit keys "Ctrl-Alt-M". Badboy will add a Mouse Click recorded at the selected location to your script tree.
Restoring Window SizeOne problem with using mouse clicks is that sometimes if windows change their size and shape then they may lay out their contents differently. This is especially true with HTML based views such as Badboy's. For this situation you can check the "Attempt to Restore Window Size" box prior to capturing the click with the "Capture" button. In this case the window size will be captured and then restored prior to executing the Click operation. Note: although Badboy will always try to resize windows if you check this option some windows may refuse to let Badboy resize them, preventing it from working. Fortunately, the most important window - Badboy's own window - should always work.
Cascading Click ItemsYou might wonder, what do I do if I know that a window that I want to click on will appear, but I don't know when? This situation appears more commonly than you might think. Most especially, it occurs when unexpected dialog boxes show during your tests - (examples are javascript Alerts, confirmation boxes, security warnings or Javascript errors). To handle these it can be very useful to be able to say "If this kind of window ever appears, click on it to make it go away". This is exactly what Badboy allows you to do with Cascading Click Items. The term "Cascading" means that the Click will apply for all items following and below the Click Item in the Script, but not outside of the Step in which the Click is positioned. When a Cascading Click Item plays, it starts a background "watchdog" that continuously looks to see if a window matching the name you have given is present. If it finds one, it executes the click. When the play position moves outside of the Step in which the Click is positioned, the watchdog is terminated.
Note: if you want Badboy to click on a window, you must often place the Cascading Click Item before the item that causes the popup to occur in the script. If you put it afterward it may not execute until after the actual popup has been closed.
A Common Problem: Capturing Modal DialogsSometimes you may want to capture a click on a window that only shows up during playback and you may find that you can't open the Click Properties dialog to capture the Click coordinates. A simple trick will help you deal with this: run a second instance of Badboy to cause the window to show, then capture the Click using the first instance. This trick works because Badboy can capture Clicks from the second window, but will still happily play the Click back on windows generated by the first instance . Using this trick you can capture a click for any kind of popup or dialog that may show.
Disadvantages of Mouse ClicksYou could potentially write your whole test using "Click" items. You might find this a very easy away to get your tests working. However there are some disadvantages of creating test scripts this way that you should seriously consider before basing significant portions of your tests on mouse clicks:
For the reasons above over-use of Click Items is not encouraged. However using them carefully and wisely will let you test things that might otherwise be impossible, and can make your testing life easier when you are confronted with difficult problems!