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.
<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.
<config ... />
<steps>
<invoke ... />
<verifyCheckbox description="Verify toppings - Mozzarella"
name="topping" value="Mozzarella"
checked="true" />
<verifyCheckbox description="Verify toppings - Gorgonzola"
name="topping" value="Gorgonzola"
checked="true" />
<verifyCheckbox description="Verify toppings - Anchovis not!"
name="topping" value="Anchovis"
checked="false" />
</steps>
</webtest>
See also: the setCheckbox and selectForm steps.