How do I read if a radio button is selected or not
This example demonstrates reading if a radio button is selected or not.
In the solution shown below, you will read if the radio button "Faimly of 2" of the "Number of people on insurance policy:" options in HICC application is selected or not using "storeChecked" command.
Note: You are reading the value of an element from the UI and initializing to a variable <Variable Name>. The notation to reuse the value of the variable in Worksoft SaaS is ${<Variable Name>}.
Solution:
# | Command | Target | Value | |
---|---|---|---|---|
Validate that the Radio button is selected | ||||
1 | storeChecked | //input[@id="rdo_family2"] | isFamilyOfTwoSelected | |
Print the selection retun value of radio button, true if it is checked, false otherwise. | ||||
2 | echo | ${isFamilyOfTwoSelected} |
Tips, Tricks, Gotchas & Best Practices:
- To understand more about selecting a radio button, click here.
- To understand more about validating the selection of radio of button, click here.
- If the above commands fail to verify that the radio button is checked then you can use the storeEval command as another alternative.
- You can also apply the same command for reading if a checkbox is checked/selected or not.