Sha256: e6a8da93f1ea5a1fe5b8b6bf2ef24488a46f1df2b30d8e97d0f65981c61ce82b

Contents?: true

Size: 1.59 KB

Versions: 77

Compression:

Stored size: 1.59 KB

Contents

module TestCentricity
  class Radio < UIElement
    attr_accessor :proxy

    def initialize(name, parent, locator, context, proxy = nil)
      @name        = name
      @parent      = parent
      @locator     = locator
      @context     = context
      @alt_locator = nil
      @proxy       = proxy
      @type        = :radio
      set_locator_type
    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

77 entries across 77 versions & 2 rubygems

Version Path
testcentricity_web-3.2.0 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.11 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.10 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.9.1 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.9 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.8 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.7 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.6 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.5.1 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.5 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.4 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.3 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.2 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.1 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.1.0 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.0.20 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.0.19.1 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.0.19 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.0.18 lib/testcentricity_web/web_elements/radio.rb
testcentricity_web-3.0.17 lib/testcentricity_web/web_elements/radio.rb