Content Checks

Content Checks are a kind of Assertion Check that examines the content of the web page in the browser to see if it contains particular text that you specify.

Content Check Properties

A Content Check has a number of properties that control how it works. Below is an example of the Properties dialog showing the options that you can choose:


In a simple case you will just type in some text that you want to test for and select either "Contain" or "Not Contain" depending on whether the text is supposed to appear on the page or not. Some more complex options are described below.

You can reference Badboy variables inside your expression using the standard ${variable name} syntax.

Regular Expressions

Sometimes you can't say exactly what a page should look like but you can predict it's general form. In this case you can use the "Regex Match" option in the Assertion properties to specify a Regular Expression pattern to match the content that you want to trigger the Assertion. For example, you might want to check that a person logged in successfully by looking for the login message with an Assertion such as "Welcome [A-z0-9 ]*\. You have logged in successfully to account [0-9]*."

Matching Against Normalized Body Content

Badboy offers an advanced mode for matching content which can both make it easier to match and also enable matching in situations where it may otherwise be impossible. When the Normalized Body Content option is selected:
  • HTML is extracted from the Body element of the HTML at the time the Assertion executes instead of the time the page was loaded.
  • The HTML is processed in several ways to ensure that it matches uniformly even if the page content varies in certain ways. These include: all new lines are removed, all tags are made upper case, and all attributes are ordered similarly
Using this option can help if you have pages which write or modify their own HTML using a scripting language (such as JavaScript). Note that this option can only match content inside the HTML's body element on the page.

Badboy's Easy Assertion button always creates Assertions with Normalized Body Content enabled. You should not disable this option if you create an Assertion with the Easy Assertion button unless you are sure of what you are doing!

Common Problems

A common problem encountered when using Assertions is that the Assertion fails to trigger even though the text it is supposed to find appears visually on the page. The key to understanding this problem is to realize that the HTML source for a web page often contains special characters that do not appear visually in the browser. For example, the words "tree frog" seen visually in the browser might actually be represented as "tree frog" in the HTML source. Because Badboy tests the actual HTML source for the page it may not find the words "tree frog" entered into an Assertion.

One way to avoid these problems is to just highlight the text on the page and use the Easy Assertion button (described above). In this case Badboy will do the work to examine the source of the page and format the content in such a way to ensure that it matches. If you don't want to use the Easy Assertion method (for example, if you are writing a complex Assertion using regular expressions or Badboy variables) then you should right click and use the "View Source..." option to show the HTML source for the page that you are testing. Then you can search for the text you are trying to test and copy it exactly from the HTML source into your Assertion expression to make sure it gets accurately matched.

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