Sha256: 6563ef9742e747b231c4893fec222865467c024844695f940d525f1d79c4d5d0

Contents?: true

Size: 1.07 KB

Versions: 15

Compression:

Stored size: 1.07 KB

Contents

module Watir
  class Radio < Input

    def initialize(query_scope, selector)
      super
      @selector[:label] = @selector.delete(:text) if @selector.key?(:text)
    end

    #
    # Selects this radio button.
    #

    def set
      click unless set?
    end
    alias_method :select, :set

    #
    # Is this radio set?
    #
    # @return [Boolean]
    #

    def set?
      element_call { @element.selected? }
    end
    alias_method :selected?, :set?

    #
    # Returns the text of the associated label.
    # Returns empty string if no label is found.
    #
    # @return [String]
    #

    def text
      l = label()
      l.exist? ? l.text : ''
    end

  end # Radio

  module Container
    def radio(*args)
      Radio.new(self, extract_selector(args).merge(tag_name: "input", type: "radio"))
    end

    def radios(*args)
      RadioCollection.new(self, extract_selector(args).merge(tag_name: "input", type: "radio" ))
    end
  end # Container

  class RadioCollection < InputCollection
    private

    def element_class
      Radio
    end
  end # RadioCollection
end # Watir

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
watir-6.13.0 lib/watir/elements/radio.rb
watir-6.12.0 lib/watir/elements/radio.rb
watir-6.11.0 lib/watir/elements/radio.rb
watir-6.11.0.beta2 lib/watir/elements/radio.rb
watir-6.11.0.beta1 lib/watir/elements/radio.rb
watir-6.10.3 lib/watir/elements/radio.rb
watir-6.10.2 lib/watir/elements/radio.rb
watir-6.10.0 lib/watir/elements/radio.rb
watir-6.9.1 lib/watir/elements/radio.rb
watir-6.9.0 lib/watir/elements/radio.rb
watir-6.8.4 lib/watir/elements/radio.rb
watir-6.8.3 lib/watir/elements/radio.rb
watir-6.8.2 lib/watir/elements/radio.rb
watir-6.8.1 lib/watir/elements/radio.rb
watir-6.8.0 lib/watir/elements/radio.rb