Class: FormObjectModel::Form::RadioField

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

Instance Attribute Summary

Attributes inherited from Field

#locator, #name, #page

Instance Method Summary collapse

Instance Method Details

#fill(value) ⇒ Object

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



38
39
40
41
42
43
44
# File 'lib/form_object_model/form.rb', line 38

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)


46
47
48
49
# File 'lib/form_object_model/form.rb', line 46

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

#valueObject



51
52
53
54
# File 'lib/form_object_model/form.rb', line 51

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