Module: Watir::SelectListCommonWatir

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

Overview

these methods work for IE and for Firefox

Instance Method Summary collapse

Instance Method Details

#selected_itemObject Also known as: selected

selected_item is a convenience filter for selected_items returns

nil if no options selected
'text' string if one option selected.
or selected_items if more than one option selected


385
386
387
388
389
390
391
392
# File 'lib/watirloo/extension/watir_ducktape.rb', line 385

def selected_item
  arr = selected_items # limit to one mehtod call
  case arr.size
  when 0 then nil
  when 1 then arr[0]
  else arr
  end
end

#selected_itemsObject

selected_items examples

[] =>  nothing selected
['item'] => if one selected
['item1', 'item2', 'item3'] => several items selected


376
377
378
# File 'lib/watirloo/extension/watir_ducktape.rb', line 376

def selected_items 
  getSelectedItems
end

#selected_valueObject

convinience method as a filter for select_values returns: nil for nothing selected. single value if only once selected or just or returns selected_values



439
440
441
442
443
444
445
446
# File 'lib/watirloo/extension/watir_ducktape.rb', line 439

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

#selected_valuesObject

similar to selected_items but returns array of option value attributes



423
424
425
426
427
428
429
430
431
432
# File 'lib/watirloo/extension/watir_ducktape.rb', line 423

def selected_values
  assert_exists
  arr = []
  @o.each do |thisItem|
    if thisItem.selected
      arr << thisItem.value
    end
  end
  return arr
end