Sha256: 1a7489e3abfcb51f0a2eaca99bd8681a9d800f129e55a0b0087e07bc8778d630

Contents?: true

Size: 1.3 KB

Versions: 6

Compression:

Stored size: 1.3 KB

Contents

module TestCentricity
  module AppElements
    class AppCheckBox < AppUIElement
      def initialize(name, parent, locator, context)
        super
        @type = :checkbox
      end

      # Is checkbox checked?
      #
      # @return [Boolean]
      # @example
      #   remember_me_checkbox.checked?
      #
      def checked?
        obj = element
        object_not_found_exception(obj)
        if Environ.is_macos?
          state = obj.value
          state.to_bool
        else
          obj.selected?
        end
      end

      # Set the check state of a checkbox object.
      #
      # @example
      #   remember_me_checkbox.check
      #
      def check
        set_checkbox_state(true)
      end

      # Uncheck a checkbox object.
      #
      # @example
      #   remember_me_checkbox.uncheck
      #
      def uncheck
        set_checkbox_state(false)
      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 = element
        object_not_found_exception(obj)
        if state
          obj.click unless obj.selected?
        else
          obj.click if obj.selected?
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
testcentricity_apps-4.0.15 lib/testcentricity_apps/app_elements/checkbox.rb
testcentricity_apps-4.0.14 lib/testcentricity_apps/app_elements/checkbox.rb
testcentricity_apps-4.0.13 lib/testcentricity_apps/app_elements/checkbox.rb
testcentricity_apps-4.0.12 lib/testcentricity_apps/app_elements/checkbox.rb
testcentricity_apps-4.0.11 lib/testcentricity_apps/app_elements/checkbox.rb
testcentricity_apps-4.0.10 lib/testcentricity_apps/app_elements/checkbox.rb