Verifying the status of a radio button or check box

You can use the dynamic find() API to verify the status of a radio button or check box during playback, such as whether the control was selected or not.

This example shows you how to verify whether a radio button was selected during playback. When you use this example, if the radio button is found to be cleared, it is identified as not selected and is written to the log. If the radio button is found to be selected, it is clicked during playback.

private void checkRadionButtonStatus() {

State curState = radioButton_group1Milk().getState(); //radioButton_group1Milk is a mapped test object, recorded using the HCL OneTest
                  UI recorder.

System.out.println(curState.getState());
// Test whether the radio button is selected.
sleep(2);
if (curState.isNotSelected()) {
logInfo(" -- Html.INPUT.radio Button is NOT selected by default."); // The playback log captures the information.

} else {
System.out.println("Selected!!!");
logInfo(" -- HTML Radio Button selected by default,");
//Perform other actions such as click, etc..
}
}

This example modifies the previous example to verify the status of an HTML check box, and verify whether it was selected during playback. When you use this example, if the check box is found to be cleared, it is identified as not selected and is written to the log. If the check box is found to be selected, it is clicked during playback.

private void checBoxStatus() {

State currentStatus_checkBox = checkBox_ctl00EnrollmentConten().getState();// checkBox_ctl00EnrollmentConten is a mapped test object, recorded using the HCL OneTest
                  UI recorder.

System.out.println(currentStatus_checkBox.getState());
// Test whether the check box is selected.
sleep(2);
if (currentStatus_checkBox.isNotSelected()) {
logInfo(" -- Html.INPUT.checkbox is NOT selected by default.");
} else {
System.out.println("Selected!!!");
logInfo(" -- Html.INPUT.checkbox is selected by default,"); // The playback log captures the information.
//Perform other actions such as click, etc..
}
} 
These examples show how to use the isNotSelected() method. You can adapt these examples for your requirements.