Sha256: fb11fb05a4e45c643404c49d3970369819fe336e08aa0d646ef80ca7869441d7

Contents?: true

Size: 1.54 KB

Versions: 32

Compression:

Stored size: 1.54 KB

Contents

module TestCentricity
  class Radio < UIElement
    attr_accessor :proxy

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

    # Does radio button object exists?
    #
    # @return [Boolean]
    # @example
    #   accept_terms_radio.exists?
    #
    def exists?
      obj, _ = find_object(:all)
      obj != nil
    end

    # Is radio button selected?
    #
    # @return [Boolean]
    # @example
    #   accept_terms_radio.selected?
    #
    def selected?
      obj, _ = find_element(:all)
      object_not_found_exception(obj, 'Radio')
      obj.checked?
    end

    # Set the select state of a radio button object.
    #
    # @param state [Boolean] true = selected / false = unselected
    # @example
    #   accept_terms_radio.set_selected_state(true)
    #
    def set_selected_state(state)
      obj, _ = find_element(:all)
      object_not_found_exception(obj, 'Radio')
      invalid_object_type_exception(obj, 'radio')
      if @proxy.nil?
        obj.set(state)
      else
        @proxy.click unless state == obj.checked?
      end
    end

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

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

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
testcentricity_web-0.9.9.1 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.9 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.8 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.7 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.6.3 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.6.2 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.6.1 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.6 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.5.1 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.5 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.4 lib/testcentricity_web/elements/radio.rb
testcentricity_web-0.9.3.4 lib/testcentricity_web/elements/radio.rb