class TestCentricity::CheckBox

Attributes

proxy[RW]

Public Class Methods

new(name, parent, locator, context, proxy = nil) click to toggle source
# File lib/testcentricity_web/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/web_elements/checkbox.rb, line 110
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/web_elements/checkbox.rb, line 33
def checked?
  obj, = find_element(:all)
  object_not_found_exception(obj, 'Checkbox')
  obj.checked?
end
disabled?() click to toggle source

Is checkbox disabled (not enabled)?

@return [Boolean] @example

remember_me_checkbox.disabled?
# File lib/testcentricity_web/web_elements/checkbox.rb, line 66
def disabled?
  visibility = @proxy.nil? ? true : :all
  obj, type = find_element(visibility)
  object_not_found_exception(obj, type)
  obj.disabled?
end
exists?() click to toggle source

Does checkbox object exists?

@return [Boolean] @example

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

Return checkbox caption

@return [Boolean] @example

remember_me_checkbox.get_value
Calls superclass method
# File lib/testcentricity_web/web_elements/checkbox.rb, line 79
def get_value
  @proxy.nil? ? super : @proxy.get_value
end
highlight(duration = 1) click to toggle source

Highlight a checkbox with a 3 pixel wide, red dashed border for the specified wait time. If wait time is zero, then the highlight will remain until the page is refreshed

@param duration [Integer or Float] wait time in seconds @example

remember_me_checkbox.highlight(3)
Calls superclass method
# File lib/testcentricity_web/web_elements/checkbox.rb, line 137
def highlight(duration = 1)
  @proxy.nil? ? super : @proxy.highlight(duration)
end
indeterminate?() click to toggle source

Is checkbox state indeterminate?

@return [Boolean] @example

remember_me_checkbox.indeterminate?
# File lib/testcentricity_web/web_elements/checkbox.rb, line 45
def indeterminate?
  state = get_attribute('indeterminate')
  state.boolean? ? state : state == 'true'
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/web_elements/checkbox.rb, line 89
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
uncheck() click to toggle source

Uncheck a checkbox object.

@example

remember_me_checkbox.uncheck
# File lib/testcentricity_web/web_elements/checkbox.rb, line 119
def uncheck
  set_checkbox_state(state = false)
end
unhighlight() click to toggle source

Restore a highlighted checkbox's original style

@example

remember_me_checkbox.unhighlight
Calls superclass method
# File lib/testcentricity_web/web_elements/checkbox.rb, line 146
def unhighlight
  @proxy.nil? ? super : @proxy.unhighlight
end
verify_check_state(state, enqueue = false) click to toggle source
# File lib/testcentricity_web/web_elements/checkbox.rb, line 123
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
visible?() click to toggle source

Is checkbox visible?

@return [Boolean] @example

remember_me_checkbox.visible?
Calls superclass method
# File lib/testcentricity_web/web_elements/checkbox.rb, line 56
def visible?
  @proxy.nil? ? super : @proxy.visible?
end