Class: FormObjectModel::RadioField

Inherits:
Field
  • Object
show all
Defined in:
lib/form_object_model/radio_field.rb

Instance Attribute Summary

Attributes inherited from Field

#locator, #name, #page

Instance Method Summary collapse

Methods inherited from Field

#==

Instance Method Details

#fill(value) ⇒ Object

This lets you select the radio button by it’s label instead of id



4
5
6
7
8
9
10
# File 'lib/form_object_model/radio_field.rb', line 4

def fill(value)
  if button = button_for(value)
    button.set(true)
  else
    raise "Could not find button with locator '#{locator}' and label '#{value}'"
  end
end

#has_value?(value) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/form_object_model/radio_field.rb', line 12

def has_value?(value)
  button = button_for(value)
  button && %w(checked true).include?(button['checked'])
end

#valueObject



17
18
19
20
# File 'lib/form_object_model/radio_field.rb', line 17

def value
  element = checked_element
  element && element.value
end