Module: Watir::CheckboxGroupCommonWatir

Included in:
FireWatir::CheckboxGroup, CheckboxGroup
Defined in:
lib/watirloo/extension/watir_ducktape.rb

Instance Method Summary collapse

Instance Method Details

#selected_checkboxesObject

returns selected checkboxes as array when empty [] then nothing is selected when [checkbox, checkbox] = array of checkboxes that are selected that you can iterate over for tests.



233
234
235
# File 'lib/watirloo/extension/watir_ducktape.rb', line 233

def selected_checkboxes
  @o.select {|cb| cb.isSet?}
end

#selected_valueObject Also known as: selected

convenience method as a filter for selected_values returns:

nil => when no checkbox is set
'value' => if one checkbox is set
or bypass filter and return selected_values array


242
243
244
245
246
247
248
249
# File 'lib/watirloo/extension/watir_ducktape.rb', line 242

def selected_value
  arr = selected_values
  case arr.size
  when 0 then nil
  when 1 then arr[0]
  else arr      
  end
end

#set?Boolean Also known as: checked?

if at least one checkbox is selected then the group is considered set

Returns:

  • (Boolean)


259
260
261
# File 'lib/watirloo/extension/watir_ducktape.rb', line 259

def set?
  (selected_checkboxes != []) ? true : false
end