def check_checkbox(checkBoxName, values=nil)
        elements = find_checkboxes_by_name(checkBoxName)
        if values
          values.class == Array ? arys = values : arys = [values]          
          arys.each { |cbx_value|
            elements.each do |elem|
              elem.click if elem.attribute('value') == cbx_value && !elem.selected?
            end
          }
        else
          the_checkbox = elements[0] 
          the_checkbox.click unless the_checkbox.selected?
        end
      end
def check_checkbox(checkBoxName, values=nil)
        elements = find_checkboxes_by_name(checkBoxName)
        if values
          values.class == Array ? arys = values : arys = [values]          
          arys.each { |cbx_value|
            elements.each do |elem|
              elem.click if elem.attribute('value') == cbx_value && !elem.selected?
            end
          }
        else
          the_checkbox = elements[0] 
          the_checkbox.click unless the_checkbox.selected?
        end
      end
Check a checkbox
 Usage:
   check_checkbox("agree")
   check_checkbox("agree", "true")