How to verify checkbox is checked/unchecked ?

Use if statement to verify if checkbox is selected or not. Based on condition specified in if statement user can select or unselect checkbox.

Below is code snippet:

navigateTo("https://demosite.appvance.com/");
click(link("/t/bags"));
/*If Condition true, enters loop and select check box,used not operation here*/
if (!(isChecked(checkbox(0,_near(label("Under $10.00")))))){
click(checkbox(0,_near(label("Under $10.00"))));
}
click(link("Home"));
click(div("panel-body product-body text-center[2]"));
click(span("Ruby on Rails Baseball Jersey"));
click(submit("Add To Cart"));
click(submit("btn btn-lg btn-success"));
setValue(emailbox("form-control title"),"Test@appvance.com");
click(submit("Continue"));
/*Condition true, as checkbox is already selected unselect the checkbox*/
if (isChecked(checkbox("order_use_billing"))){
click(checkbox("order_use_billing"));
}

Select: (!(isChecked(checkbox(0,_near(label("Under $10.00")))))) returns true and click checkbox to select

Unselect: (isChecked(checkbox("order_use_billing"))) returns true and clicks on checkbox again to unselect

To verify checkbox is select and donnot unselect:

! (isChecked(checkbox("order_use_billing"))) returns false and verify checkbox is checked.