How do I validate that a particular checkbox is selected/checked
This example demonstrates validating the selected/checked 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 and then validate the selection using "verifyChecked" command.
Solution:
# | Command | Target | Value |
---|---|---|---|
Check the checkbox "Is coverage available from your or your spouse’s job?" |
|||
1 | check | //input[@name="chk_employerInsurance"] | |
Validating the checkbox is checked/selected | |||
2 | verifyChecked |
//input[@name="chk_employerInsurance"] |
Tips, Tricks, Gotchas & Best Practices:
- To understand more about selecting a checkbox, click here.
- As an alternative, you are encouraged to use waitForChecked or assertChecked commands.
- You can also use storeChecked command to read if the checkbox is checked or not. To understand more about this, click here.