35 right, 0 wrong, 1 ignored, 0 exceptions SuiteSignUpForm.TestFailureNoFname
22 right, 0 wrong, 1 ignored, 0 exceptions SuiteSignUpForm.TestSuccessWithSpecialCharacters
22 right, 0 wrong, 1 ignored, 0 exceptions SuiteSignUpForm.TestSucessfulSignup
15 right, 0 wrong, 1 ignored, 0 exceptions SuiteWebSearch.TestGoogleSearch
15 right, 0 wrong, 2 ignored, 0 exceptions SuiteWebSearch.TestYahooSearchSuccess

Test Output

 Set Up: .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SetUp
Import
com.jbergin

HtmlFixture
  WARNING: no focus element
Clear
web client restarted, cookies cleared
Javascript:on on
Show Javascript Errors:off off
Show SSL Errors:off off
Preserve:on
Set User Agent
browser restarted (cookies cleared) with user agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8


The base SetUp? page always needs the Import table at the top of this one to allow the fixture unqualified fixture name in test tables.

The second table sets some common configuration options for the fixture.

Always turn Preserve on so that named DOM elements persist between tables.

The Clear statement empties the DOM element storage at the start of each test.

The Set User Agent command was required for the yahoo search test - yahoo doesn't return results unless the request has a User Agent that looks like a real browser.

Show Javascript Errors off makes htmlunit behave like a real browser - if errors in javascript are encountered, they are ignored and the test continues (the error still gets appended to the error logs for the test).

Show SSL Errors off is a nice option for testing SSL on a test site with a fake or expired certificate.

Suites that have special SetUp? needs should all include this SetUp? page in their SetUp?

variable defined: FNAME=$blank$
variable defined: LNAME=${LNAME1}
variable defined: EMAIL=${EMAIL1}

 Included page: .HtmlFixtureDemo.IncludeTables.SubmitSignUpForm
HtmlFixture
http://localhost:83/HtmlFixtureDemo.TestSite.SignUpForm
loaded time: 346 milliseconds
resultPage
Element Focus theForm
form myForm
First Name:
Last Name:
email:
Element Focus fname
input
Set Value $blank$
Focus myForm
Element Focus lname
input
Set Value Test
Focus myForm
Element Focus email
input
Set Value bob@test.com
Focus myForm
First Name:
Last Name:
email:
Element Focus submit_registration
input submitBtn
Click
loaded time: 346 milliseconds
resultPage



This is a typical include page for submitting a form.

Note that since the Element Focus command only searches the children (recurively) of the current focus element, it is necessary to return to the form element in between each Element Focus command for the inputs of the form.

It is a good practice to display the form on the first and last focus command by placing an empty cell after the name cell in the focus command. This makes test page easy to read and also easy to see if something has gone wrong with the navigation that brings you to the form element. I also tend to display the button before the Click command to enhance test results readability.

In this demo, since the "application under test" just has a single form, the page starts with a URL. In actual practice, most include tables start by focusing on resultPage (this one would be preceded by a table that would for example click on the signup link on the home page and store the result in resultPage).


  • verify js alert
  • verify that the form is still there with the values that were set

HtmlFixture
resultPage
Javascript Message First Name is required
Element Focus theForm
form myForm
First Name:
Last Name:
email:
Element Focus fname
input
Attribute value $blank$
Focus myForm
Element Focus lname
input
Attribute value Test
Focus myForm
Element Focus email
input
Attribute value bob@test.com


This page demonstrates how a properly designed include page can allow for testing of failure in form submission. Since the include page does not contain any assertions about the results of clicking the submit button, it can be used in tests such as this one when the form constraints prevent the form from submitting.

 Set Up: .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SetUp
Import
com.jbergin

HtmlFixture
  WARNING: no focus element
Clear
web client restarted, cookies cleared
Javascript:on on
Show Javascript Errors:off off
Show SSL Errors:off off
Preserve:off
Set User Agent
browser restarted (cookies cleared) with user agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8


The base SetUp? page always needs the Import table at the top of this one to allow the fixture unqualified fixture name in test tables.

The second table sets some common configuration options for the fixture.

Always turn Preserve on so that named DOM elements persist between tables.

The Clear statement empties the DOM element storage at the start of each test.

The Set User Agent command was required for the yahoo search test - yahoo doesn't return results unless the request has a User Agent that looks like a real browser.

Show Javascript Errors off makes htmlunit behave like a real browser - if errors in javascript are encountered, they are ignored and the test continues (the error still gets appended to the error logs for the test).

Show SSL Errors off is a nice option for testing SSL on a test site with a fake or expired certificate.

Suites that have special SetUp? needs should all include this SetUp? page in their SetUp?

variable defined: FNAME=${FNAME2}
variable defined: LNAME=${LNAME2}
variable defined: EMAIL=${EMAIL2}

 Included page: .HtmlFixtureDemo.IncludeTables.SubmitSignUpForm
HtmlFixture
http://localhost:83/HtmlFixtureDemo.TestSite.SignUpForm
loaded time: 22 milliseconds
resultPage
Element Focus theForm
form myForm
First Name:
Last Name:
email:
Element Focus fname
input
Set Value "Bobby"
Focus myForm
Element Focus lname
input
Set Value o'Test III
Focus myForm
Element Focus email
input
Set Value bob_otest3@test.com.net.org
Focus myForm
First Name:
Last Name:
email:
Element Focus submit_registration
input submitBtn
Click
loaded time: 22 milliseconds
resultPage



This is a typical include page for submitting a form.

Note that since the Element Focus command only searches the children (recurively) of the current focus element, it is necessary to return to the form element in between each Element Focus command for the inputs of the form.

It is a good practice to display the form on the first and last focus command by placing an empty cell after the name cell in the focus command. This makes test page easy to read and also easy to see if something has gone wrong with the navigation that brings you to the form element. I also tend to display the button before the Click command to enhance test results readability.

In this demo, since the "application under test" just has a single form, the page starts with a URL. In actual practice, most include tables start by focusing on resultPage (this one would be preceded by a table that would for example click on the signup link on the home page and store the result in resultPage).


HtmlFixture
resultPage
Element Focus mainDiv
div myMainDiv
Thanks for signing up, "Bobby" o'Test III
Starting in minutes, loads of spam will be sent to bob_otest3@test.com.net.org
Has Text "Bobby" o'Test III
Matches Text Thanks.*will be sent to bob_otest3@test.com.net.org
matched with: Thanks for signing up, "Bobby" o'Test III Starting in minutes, loads of spam will be sent to bob_otest3@test.com.net.org



Passing data from the suite wiki page to the include page this way makes it very easy to test additional test cases once the first one is established. This test differs from .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SuiteSignUpForm.TestSucessfulSignup only in the defines at the top.

 Set Up: .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SetUp
Import
com.jbergin

HtmlFixture
  WARNING: no focus element
Clear
web client restarted, cookies cleared
Javascript:on on
Show Javascript Errors:off off
Show SSL Errors:off off
Preserve:on
Set User Agent
browser restarted (cookies cleared) with user agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8


The base SetUp? page always needs the Import table at the top of this one to allow the fixture unqualified fixture name in test tables.

The second table sets some common configuration options for the fixture.

Always turn Preserve on so that named DOM elements persist between tables.

The Clear statement empties the DOM element storage at the start of each test.

The Set User Agent command was required for the yahoo search test - yahoo doesn't return results unless the request has a User Agent that looks like a real browser.

Show Javascript Errors off makes htmlunit behave like a real browser - if errors in javascript are encountered, they are ignored and the test continues (the error still gets appended to the error logs for the test).

Show SSL Errors off is a nice option for testing SSL on a test site with a fake or expired certificate.

Suites that have special SetUp? needs should all include this SetUp? page in their SetUp?

variable defined: FNAME=${FNAME1}
variable defined: LNAME=${LNAME1}
variable defined: EMAIL=${EMAIL1}

 Included page: .HtmlFixtureDemo.IncludeTables.SubmitSignUpForm
HtmlFixture
http://localhost:83/HtmlFixtureDemo.TestSite.SignUpForm
loaded time: 20 milliseconds
resultPage
Element Focus theForm
form myForm
First Name:
Last Name:
email:
Element Focus fname
input
Set Value Bob
Focus myForm
Element Focus lname
input
Set Value Test
Focus myForm
Element Focus email
input
Set Value bob@test.com
Focus myForm
First Name:
Last Name:
email:
Element Focus submit_registration
input submitBtn
Click
loaded time: 20 milliseconds
resultPage



This is a typical include page for submitting a form.

Note that since the Element Focus command only searches the children (recurively) of the current focus element, it is necessary to return to the form element in between each Element Focus command for the inputs of the form.

It is a good practice to display the form on the first and last focus command by placing an empty cell after the name cell in the focus command. This makes test page easy to read and also easy to see if something has gone wrong with the navigation that brings you to the form element. I also tend to display the button before the Click command to enhance test results readability.

In this demo, since the "application under test" just has a single form, the page starts with a URL. In actual practice, most include tables start by focusing on resultPage (this one would be preceded by a table that would for example click on the signup link on the home page and store the result in resultPage).


HtmlFixture
resultPage
Element Focus mainDiv
div myMainDiv
Thanks for signing up, Bob Test
Starting in minutes, loads of spam will be sent to bob@test.com
Has Text Bob Test
Matches Text Thanks.*will be sent to bob@test.com
matched with: Thanks for signing up, Bob Test Starting in minutes, loads of spam will be sent to bob@test.com



The syntax at the top of this test page shows how to pass data from the suite wiki page into the include table.

Test pages should contain only:

  1. macro definitions that pass data from the suite wiki page into the include tables
  2. includes of pages from IncludeTables?
  3. assertions about the results (in practice these include assertions made with a database connection fixture as well as assertions about the html in the resultPage).

Note that the Matches Text command (which uses regular expressions) can help make the assertions more robust. This test will stil pass if the submission message is change to "Thanks for joining, your special Christmas gift link will be sent to bob@test.com"

 Set Up: .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SetUp
Import
com.jbergin

HtmlFixture
  WARNING: no focus element
Clear
web client restarted, cookies cleared
Javascript:on on
Show Javascript Errors:off off
Show SSL Errors:off off
Preserve:off
Set User Agent
browser restarted (cookies cleared) with user agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8


The base SetUp? page always needs the Import table at the top of this one to allow the fixture unqualified fixture name in test tables.

The second table sets some common configuration options for the fixture.

Always turn Preserve on so that named DOM elements persist between tables.

The Clear statement empties the DOM element storage at the start of each test.

The Set User Agent command was required for the yahoo search test - yahoo doesn't return results unless the request has a User Agent that looks like a real browser.

Show Javascript Errors off makes htmlunit behave like a real browser - if errors in javascript are encountered, they are ignored and the test continues (the error still gets appended to the error logs for the test).

Show SSL Errors off is a nice option for testing SSL on a test site with a fake or expired certificate.

Suites that have special SetUp? needs should all include this SetUp? page in their SetUp?

variable defined: SEARCH_SITE=${SEARCH_SITE2}
variable defined: QUERY_INPUT_ELEMENT_NAME=${QUERY_INPUT_ELEMENT_NAME2}
variable defined: SEARCH_BUTTON_VALUE=${SEARCH_BUTTON_VALUE2}

variable defined: SEARCH_TERM=${SEARCH_TERM1}


 Included page: .HtmlFixtureDemo.IncludeTables.SubmitSearch
HtmlFixture
http://www.google.com
loaded time: 179 milliseconds
resultPage
Element Focus q
No element with id q
Found 1 elements having attribute name with value q of type input
input
Set Value HtmlFixture Improved
Focus Parent Type form searchForm
 
   Advanced Search
   Preferences
   Language Tools
Attribute Focus value Google Search
Found 1 elements having attribute value with value Google Search of type input
input submitBtn
Click
loaded time: 364 milliseconds
resultPage


This page demonstrates a few commands that are useful when the DOM of the application under test is lacking in id and name attributes. This page can be used to submit the search form on either www.google.com or www.yahoo.com.

The Focus Parent Type command moves up the DOM from the current focus element via parent elements until it finds the first element of he indicated type. Here it is used to focus on the form element that contains the named query input even though the form element may not have an id and there may be various DOM levels between the input and the enclosing form.

The Attribute Focus command searches in the children of the current focus element for an element with the given attribute value. In this example, it allows us to focus on the submit button by its value attribute even though the submit button may not have an id or name.


HtmlFixture
resultPage
Text Focus HtmlFixture Improved
text found in 'HtmlFixture Improved'
b linkTextBold HtmlFixture Improved
Focus Parent Type a myLink SourceForge.net: HtmlFixture Improved
Matches Attribute href .*sourceforge.net/projects/htmlfixtureim.*
matched with: http://sourceforge.net/projects/htmlfixtureim/
 Set Up: .HtmlFixtureDemo.SuiteRoot.RegressionSuite.SetUp
Import
com.jbergin

HtmlFixture
  WARNING: no focus element
Clear
web client restarted, cookies cleared
Javascript:on on
Show Javascript Errors:off off
Show SSL Errors:off off
Preserve:on
Set User Agent
browser restarted (cookies cleared) with user agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.1.8) Gecko/20071015 SUSE/2.0.0.8-1.1 Firefox/2.0.0.8


The base SetUp? page always needs the Import table at the top of this one to allow the fixture unqualified fixture name in test tables.

The second table sets some common configuration options for the fixture.

Always turn Preserve on so that named DOM elements persist between tables.

The Clear statement empties the DOM element storage at the start of each test.

The Set User Agent command was required for the yahoo search test - yahoo doesn't return results unless the request has a User Agent that looks like a real browser.

Show Javascript Errors off makes htmlunit behave like a real browser - if errors in javascript are encountered, they are ignored and the test continues (the error still gets appended to the error logs for the test).

Show SSL Errors off is a nice option for testing SSL on a test site with a fake or expired certificate.

Suites that have special SetUp? needs should all include this SetUp? page in their SetUp?

variable defined: SEARCH_SITE=${SEARCH_SITE1}
variable defined: QUERY_INPUT_ELEMENT_NAME=${QUERY_INPUT_ELEMENT_NAME1}
variable defined: SEARCH_BUTTON_VALUE=${SEARCH_BUTTON_VALUE1}

variable defined: SEARCH_TERM=${SEARCH_TERM1}


 Included page: .HtmlFixtureDemo.IncludeTables.SubmitSearch
HtmlFixture
http://www.yahoo.com
loaded time: 92 milliseconds
resultPage
Element Focus p
input
Set Value HtmlFixture Improved
Focus Parent Type form searchForm
Attribute Focus value Web Search
Found 1 elements having attribute value with value Web Search of type input
input submitBtn
Click
loaded time: 86 milliseconds
resultPage


This page demonstrates a few commands that are useful when the DOM of the application under test is lacking in id and name attributes. This page can be used to submit the search form on either www.google.com or www.yahoo.com.

The Focus Parent Type command moves up the DOM from the current focus element via parent elements until it finds the first element of he indicated type. Here it is used to focus on the form element that contains the named query input even though the form element may not have an id and there may be various DOM levels between the input and the enclosing form.

The Attribute Focus command searches in the children of the current focus element for an element with the given attribute value. In this example, it allows us to focus on the submit button by its value attribute even though the submit button may not have an id or name.


HtmlFixture
resultPage
Text Focus SourceForge
text found in 'SourceForge.net: Files'
 a linkText SourceForge.net: Files
Focus Parent Type div myResultDiv
Type Focus a
Found 0 elements of type a[1]
Found 1 elements of type a
1 myLink SourceForge.net: Files
Matches Attribute href group_id=214958
matched with: group_id=214958