- Print
- DarkLight
Checkbox and radio button assertions
Checkbox and radio button assertions
Autify's Checkbox Assertions allow you to assert whether an element is checked/unchecked (selected/unselected). You can also assert whether a check box or radio button is valid or invalid (selectable or not selectable).
However, depending on the implementation of the target web application, you may get unexpected test results. In this article, you will learn how to troubleshoot issues related to checkboxes.
During test runs, assertions to check if a checkbox is selected/unselected fail
When the target element is not an input element, whether a checkbox is selected/unselected is determined by Autify's ML (Machine Learning). If the accuracy is not sufficient, it will incorrectly determine the selected/unselected status of the element and display the following error message.
Error message examples:
The checkbox should be unselected, but it is selected.
The checkbox should be selected, but it is not.
In this case, you may be able to solve the problem using one of the following functions:
If you're using the Quick Element Update feature or a locator, the key is to select an input element. This allows Autify to see the selection status of the input element (checked attribute), which may allow it to correctly determine the selection status.
If the checkbox is not implemented using an input element (for example, the checkbox is created by applying a checkbox-like style to a div or span tag), you will need to use a JS Step to validate the style. Visual regression testing on the element can also correctly determine the selection status.
Checkbox assertion step cannot be added during recording
If you have implemented a custom checkbox and have hidden the checkbox's input element using display: none
, for example, Autify Recorder will not be able to detect the element and will not display the valid/invalid assertion command ("Element Should Be Enabled" and "Element Should Be Disabled"), preventing you from selecting it.
You can add an assertion to check whether an element is invalid (or valid) by displaying the input element. To do this, open DevTools during recording and temporarily delete the style display: none
for the input element. However, the input element will not be displayed in the test result, so the target element will not be focused in the test result screenshot.
If the issue is still not resolved...
Please contact our customer support team. We will help you resolve the issue.