The "Check/Uncheck" command can only be used on input elements with the type attribute "checkbox". If it is applied to a different element, you will see the error message Cannot find a UI element for this command <error details>
.
To fix this, follow one of the two following methods:
1. Search for an input element with the type attribute "checkbox"
- The
<error details>
might display a message likePossible candidate is {key=***, value=***}
, providing information about a suitable UI element. Use this information as a reference. - Temporarily hide the currently specified UI element (see figure below) to check for other suitable input elements.
- Use developer tools to inspect the element type. An input element has the following characteristics:
- UI element name: "***" checkbox
- Locator:
- CSS: Starts with "input".
Example: css=input[name=***]
- XPath: Ends with "input".
Example: xpath=//***/input[1]
- CSS: Starts with "input".
If a suitable UI element is found, specify it for the "Check/Uncheck" command.
2. Change to Click command
If no suitable UI element is found, you cannot use the "Check/Uncheck" command for that checkbox. Instead, use the Click command.
By following these steps, you can resolve the error and correctly interact with checkboxes in your UI tests.