class TestCentricity::CheckBox

Attributes

proxy[RW]

Public Class Methods

new(name, parent, locator, context, proxy = nil) click to toggle source
# File lib/testcentricity/web_elements/checkbox.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        = :checkbox
  set_locator_type
end

Public Instance Methods

check() click to toggle source

Set the check state of a checkbox object.

@example

remember_me_checkbox.check
# File lib/testcentricity/web_elements/checkbox.rb, line 66
def check
  set_checkbox_state(true)
end
checked?() click to toggle source

Is checkbox checked?

@return [Boolean] @example

remember_me_checkbox.checked?
# File lib/testcentricity/web_elements/checkbox.rb, line 33
def checked?
  obj, = find_element(:all)
  object_not_found_exception(obj, 'Checkbox')
  obj.checked?
end
exists?() click to toggle source

Does checkbox object exists?

@return [Boolean] @example

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

Set the check state of a checkbox object.

@param state [Boolean] true = checked / false = unchecked @example

remember_me_checkbox.set_checkbox_state(true)
# File lib/testcentricity/web_elements/checkbox.rb, line 45
def set_checkbox_state(state)
  obj, = find_element(:all)
  object_not_found_exception(obj, 'Checkbox')
  invalid_object_type_exception(obj, 'checkbox')
  if @proxy.nil?
    if obj.native.attribute('ot') == 'JCheckBox'
      expected = state.to_bool
      obj.click unless expected == obj.checked?
    else
      obj.set(state)
    end
  else
    @proxy.click unless state == obj.checked?
  end
end
set_siebel_checkbox_state(state) click to toggle source

Set the check state of a Siebel OUI JCheckBox object.

@param state [Boolean] true = checked / false = unchecked @example

remember_me_checkbox.set_siebel_checkbox_state(true)
# File lib/testcentricity/web_elements/checkbox.rb, line 92
def set_siebel_checkbox_state(state)
  obj, = find_element
  object_not_found_exception(obj, 'Siebel checkbox')
  raise "UI #{object_ref_message} is not a Siebel CheckBox object" unless get_siebel_object_type == 'JCheckBox'
  expected = state.to_bool
  obj.click unless expected == obj.checked?
end
uncheck() click to toggle source

Uncheck a checkbox object.

@example

remember_me_checkbox.uncheck
# File lib/testcentricity/web_elements/checkbox.rb, line 75
def uncheck
  set_checkbox_state(false)
end
verify_check_state(state, enqueue = false) click to toggle source
# File lib/testcentricity/web_elements/checkbox.rb, line 79
def verify_check_state(state, enqueue = false)
  actual = checked?
  enqueue ?
      ExceptionQueue.enqueue_assert_equal(state, actual, "Expected checkbox #{object_ref_message}") :
      assert_equal(state, actual, "Expected checkbox #{object_ref_message} to be #{state} but found #{actual} instead")
end