Webtest WebTest GitHub Home

Core Step verifyCheckbox

Description

This step is used to verify the state of a checkbox (checked/unchecked). A particular checkbox can be specified via name and optionally value (or alternatively by fieldIndex).

Parameters

checked
Required? yes
Specifies if the checkbox shall be checked (true) or unchecked (false).
name
Required? yes
The xpath of the input field of interest. One of name, htmlId or xpath is required.
description
Required? no
The description of this test step.
fieldIndex
Required? no
The index (starting at 0) of the field of interest (if more than one).
formName
Required? no
The name of the form containing the field of interest.
htmlId
Required? yes/no
The id of the input field of interest. One of name, htmlId or xpath is required.
value
Required? no
The value of the input field of interest.
xpath
Required? yes/no
The xpath of the input field of interest. One of name, htmlId or xpath is required.

Details

Here is a simple example for verifying that a particular checkbox is not selected. The checkbox is uniquely identified by its name.

verifyCheckbox 1
<webtest name="Check all links on current page, on subpages and on their subpages">
  <config ... />
  <steps>
    <invoke ... />
        <verifyCheckbox
            description="Verify that option is not selected"
            name="anchovis"
            checked="false"/>
  </steps>
</webtest>

A more complex scenario would allow multiple checkboxes that all have the same name but different values. The resulting request would also contain multiple value for one parameter (the checkbox name). Each of the parameter values corresponds to the value of a checked checkbox.
In order to uniquely identify checkboxes like this for verification, an optional value attribute can be specified as shown in the next example.

verifyCheckbox 2
<webtest name="Place order and verify">
  <config ... />
  <steps>
    <invoke ... />
        <verifyCheckbox description="Verify toppings - Mozzarella"
            name="toppingvalue="Mozzarella"
            checked="true" />
        <verifyCheckbox description="Verify toppings - Gorgonzola"
            name="toppingvalue="Gorgonzola"
            checked="true" />
        <verifyCheckbox description="Verify toppings - Anchovis not!"
            name="toppingvalue="Anchovis"
            checked="false" />
  </steps>
</webtest>

See also: the setCheckbox and selectForm steps.