Sha256: 936c1a1c88dd47537bf6fa5a1bb7f8114d2f63cec97aaef99d8a557603218be1

Contents?: true

Size: 1.29 KB

Versions: 6

Compression:

Stored size: 1.29 KB

Contents

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

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

      # Set the selected state of a radio button object.
      #
      # @example
      #   unicode_radio.select
      #
      def select
        set_selected_state(true)
      end

      # Unselect a radio button object.
      #
      # @example
      #   unicode_radio.unselect
      #
      def unselect
        set_selected_state(false)
      end

      # Set the selected state of a radio button object.
      #
      # @param state [Boolean] true = selected / false = unselected
      # @example
      #   ascii_radio.set_selected_state(true)
      #
      def set_selected_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/radio.rb
testcentricity_apps-4.0.14 lib/testcentricity_apps/app_elements/radio.rb
testcentricity_apps-4.0.13 lib/testcentricity_apps/app_elements/radio.rb
testcentricity_apps-4.0.12 lib/testcentricity_apps/app_elements/radio.rb
testcentricity_apps-4.0.11 lib/testcentricity_apps/app_elements/radio.rb
testcentricity_apps-4.0.10 lib/testcentricity_apps/app_elements/radio.rb