WebTest Reference

This page lists all available methods in the WebTest fixture for customer-friendly web testing through FitNesse and Selenium. See main WebTest page for more information (especially on getting started). Method arguments are marked as bold.

WebTest does a lot of smart mapping to identify fields, button and elements by captions, names, DOM element IDs and contained text. In most cases, you should be able to identify any element by the text that is actually displayed to the user on the screen. You can also use the DOM element ID (tests will run faster if you do).

Browser operations

  • Start the browser (call this method to initialise the test)
start browserbrowser namewith selenium console onselenium rc hostat portselenium rc portand scripts attest site url
  • Shut down the browser (call this method on the end of the test)
shutdown browser
  • navigate to a URL during the test (change active page)
user opens urltest site url
  • check current browser URL
page url issome url
  • check that the page loads fully within given time (use after user opens url)
page reloads in less thantimeseconds

Page validations

  • check that page contains some text (regardless of whether text is visible or not)
page contains textsome text
  • check that text does not appear anywhere on the page (including hidden parts)
page does not contain textsome text
  • check that page contains an element (hidden or visible)
page contains elementelement
  • check that page does not contain an element (hidden or visible)
page does not contain elementelement
elementelementis visible
  • check whether an element exists but is hidden
elementelementis not visible
  • check whether an element is disabled
elementelementis disabled
  • check whether an element is enabled
elementelementis enabled
  • check whether a button is disabled (can also locate buttons by captions/values)
buttonbuttonis disabled
  • check whether a button is enabled (can also locate buttons by captions/values)
buttonbuttonis enabled
  • check whether a check box is disabled (can also locate check boxes by values)
check boxcheck boxis disabled
  • check whether a check box is enabled (can also locate check boxes by values)
check boxcheck boxis enabled
  • check whether a check box is checked (confirmed)
check boxcheck boxis checked

or

check boxcheck boxis selected
  • check whether a check box is not checked (confirmed)
check boxcheck boxis not checked

or

check boxcheck boxis not selected
  • check whether a radio button is selected (confirmed)
radio buttonradio buttonis checked

or

radio buttonradio buttonis selected
  • check whether a check box is not checked (confirmed)
radio buttonradio buttonis not checked

or

radio buttonradio buttonis not selected
  • check whether a field is editable
fieldfieldis editable
  • check whether a field is disabled (not editable)
fieldfieldis not editable
fieldfieldis empty
  • check whether a text field or area contains given text (as a substring)
fieldfieldcontains texttext
  • check whether an element contains given text (as a substring). this can be used to check for text labels.
elementelementcontains texttext
  • check value of an input element
checkvalue offieldistext
  • check text in a DOM element (can be used to check for labels)
checktext inelementistext
  • check that a JavaScript alert pops up with a given message (will confirm the alert as well)
alert ismessage

or (this will also print the current value if it is different then expected)

checkalertmessage
  • print the current JavaScript alert, and confirm it
showalert
  • check that a JavaScript confirmation pops up with a given message (will confirm the box as well)
checkconfirmation message
  • print the current JavaScript confirmation, and confirm it
showconfirmation
  • check the selected option in a select/drop-down box by label
checkselected option inselect boxisvalue
  • list available options in a drop down box (the second row must contain text value, this is an ArrayFixture)
listselect boxcontains options
value
value 1
value 2

or

drop downselect boxcontains options
value
value 1
value 2

Actions

  • trigger a DOM event manually. Don't prefix the element with on (use change and not onchange). You can fire any applicable DOM event with this.
fire eventevent nameforpage element
  • click on any element
user clicks onpage element
  • click on a button (will fail if the element is not a button). This method can locate buttons by value as well.
user clicks onbuttonbutton
  • click on a check box(will fail if the element is not a check box). This method can locate check boxes by value as well.
user clicks oncheck boxcheck box
  • click on a radio button(will fail if the element is not a radio button). This method can locate radio buttons by value as well.
user clicks onradio buttonradio button
  • select an option from a select/drop-down box
user selectsoptionfromselect box
  • type text into a text field
user typestextinto fieldfield

Asynchonous (AJAX) validations

  • pause for a number of seconds
pausetimeseconds
  • wait for an element to appear
waittimeseconds for elementelementto appear
  • wait for an element to disappear
waittimeseconds for elementelementto disappear
  • wait for text to appear anywhere in the page (visible or hidden)
waittimeseconds for texttextto appear
  • wait for text to disappear from the page (visible or hidden)
waittimeseconds for texttextto disappear
  • wait for an input field to get certain value
waittimeseconds for fieldfield to contain texttext
  • wait for an element to contain certain text
waittimeseconds for elementelement to contain texttext

Personal Tools