class TestCentricity::Radio

Attributes

proxy[RW]

Public Class Methods

new(name, parent, locator, context, proxy = nil) click to toggle source
# File lib/testcentricity/web_elements/radio.rb, line 5
def initialize(name, parent, locator, context, proxy = nil)
  @name        = name
  @parent      = parent
  @locator     = locator
  @context     = context
  @alt_locator = nil
  @proxy       = proxy
  @type        = :radio
  set_locator_type
end

Public Instance Methods

exists?() click to toggle source

Does radio button object exists?

@return [Boolean] @example

accept_terms_radio.exists?
# File lib/testcentricity/web_elements/radio.rb, line 22
def exists?
  obj, = find_object(:all)
  obj != nil
end
select() click to toggle source

Set the selected state of a radio button object.

@example

accept_terms_radio.select
# File lib/testcentricity/web_elements/radio.rb, line 61
def select
  set_selected_state(true)
end
selected?() click to toggle source

Is radio button selected?

@return [Boolean] @example

accept_terms_radio.selected?
# File lib/testcentricity/web_elements/radio.rb, line 33
def selected?
  obj, = find_element(:all)
  object_not_found_exception(obj, 'Radio')
  obj.checked?
end
set_selected_state(state) click to toggle source

Set the select state of a radio button object.

@param state [Boolean] true = selected / false = unselected @example

accept_terms_radio.set_selected_state(true)
# File lib/testcentricity/web_elements/radio.rb, line 45
def set_selected_state(state)
  obj, = find_element(:all)
  object_not_found_exception(obj, 'Radio')
  invalid_object_type_exception(obj, 'radio')
  if @proxy.nil?
    obj.set(state)
  else
    @proxy.click unless state == obj.checked?
  end
end
unselect() click to toggle source

Unselect a radio button object.

@example

accept_terms_radio.unselect
# File lib/testcentricity/web_elements/radio.rb, line 70
def unselect
  set_selected_state(false)
end