How do I select/check a checkbox
This example demonstrates how to select/check a checkbox.
In the solution shown below, you will select/check the checkbox option "Is coverage available from your or your spouse’s job?" in the HICC application using the "check" command.
Solution:
# | Command | Target | Value |
---|---|---|---|
Check the checkbox "Is coverage available from your or your spouse’s job?" |
|||
1 | check | //input[@name="chk_employerInsurance"] |
Tips, Tricks, Gotchas & Best Practices:
- To understand more about validating a checkbox is checked/selected, click here.
- In some cases, you will see that some checkboxes are non-editable then you will need to check the editability of the checkbox. You can use the assertEditable command or verifyEditable command before performing any action (click/check) on the checkbox to confirm it is enabled for edit.
- If the options of checkbox does not have an unique "id" in any application, you can provide a temporary "id" of your choice using the command assignId. Then you can use that "id" for identifying the element.
- If the check command fails, you can perform the action with the below-mentioned alternatives.
- You can use either the click or mouseDown command to select the checkbox.
- If the above-mentioned commands fail to perform the action then you can use the runScript command to select the checkbox.