Class: Watir::RadioGroup

Inherits:
Object show all
Includes:
RadioCheckGroup, RadioCheckGroupCommonWatir, RadioGroupCommonWatir
Defined in:
lib/watirloo/extension/watir_ducktape.rb

Overview

radios that share the same :name attribute form a RadioGroup. RadioGroup semantically behaves like single select list box usage: this class is accessed by Watir::Container#radio_group RadioGroup semantically behaves like single select list box.

per HTML401: -

"If no radio button in a set sharing the same control name 
is initially 'on', user agent behavior for choosing which 
control is initially 'on' is undefined

The idea of having all radios off makes no sense but in the wild you can see lots of examples. it would be better to just have a single select list box with no items selected instead of radios. The point of having radios is that at least one radio is ‘ON’ providing a default value for the group

@browser = Watir::IE.attach :url, //
@browser.radio_group('food') # => RadioGroup with :name, 'food'

Instance Method Summary collapse

Methods included from RadioGroupCommonWatir

#selected_radio, #selected_values, #set?

Methods included from RadioCheckGroup

#get_by_value, #values

Methods included from RadioCheckGroupCommonWatir

#[], #get_by_position, #get_by_value, #set, #size, #values

Constructor Details

#initialize(container, how, what) ⇒ RadioGroup

Returns a new instance of RadioGroup.



139
140
141
142
143
144
# File 'lib/watirloo/extension/watir_ducktape.rb', line 139

def initialize(container, how, what)
  @container = container
  @how = how
  @what = what
  @o = locate
end

Instance Method Details

#nameObject



146
147
148
# File 'lib/watirloo/extension/watir_ducktape.rb', line 146

def name
  @name
end

#selected_valueObject Also known as: selected

which value is selected?. returns value text as string So per HTML401 spec I am not sure if we should ever have empyt array returned here if you do get empty array then I would speak with developers to fix this and explicity provide checked for one radio on page load.



168
169
170
# File 'lib/watirloo/extension/watir_ducktape.rb', line 168

def selected_value
  selected_radio.ole_object.invoke('value')
end