Sha256: f0cd625f6cdc86a6d86a9b1e160d8faeeb1ef4f817114305e696871eb9dbd7d3

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

module TestCentricity
  class CheckBox < UIElement

    def initialize(parent, locator, context)
      @parent  = parent
      @locator = locator
      @context = context
      @type    = :checkbox
      @alt_locator = nil
    end

    # Is checkbox checked?
    #
    # @return [Boolean]
    # @example
    #   remember_me_checkbox.checked?
    #
    def checked?
      obj, _ = find_element
      object_not_found_exception(obj, 'Checkbox')
      obj.checked?
    end

    # Set the check state of a checkbox object.
    #
    # @param state [Boolean] true = checked / false = unchecked
    # @example
    #   remember_me_checkbox.set_checkbox_state(true)
    #
    def set_checkbox_state(state)
      obj, _ = find_element
      object_not_found_exception(obj, 'Checkbox')
      invalid_object_type_exception(obj, 'checkbox')
      obj.set(state)
    end

    def verify_check_state(state, enqueue = false)
      actual = checked?
      enqueue ?
          ExceptionQueue.enqueue_assert_equal(state, actual, "Expected #{@locator}") :
          assert_equal(state, actual, "Expected #{@locator} to be #{state} but found #{actual} instead")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
testcentricity_web-0.6.6.1 lib/testcentricity_web/elements/checkbox.rb
testcentricity_web-0.6.6 lib/testcentricity_web/elements/checkbox.rb