Sha256: 24162e1d145fc5d6f4169f6ee9b47b69f2fe34c99da70ca90a8d00e56c341645

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module Watir

  #
  # Class representing button elements.
  #
  # This class covers both <button> and <input type="submit|reset|image|button" /> elements.
  #

  class Button < HTMLElement

    inherit_attributes_from Watir::Input

    VALID_TYPES = %w[button reset submit image]

    #
    # Returns the text of the button.
    #
    # For input elements, returns the "value" attribute.
    # For button elements, returns the inner text.
    #
    # @return [String]
    #

    def text
      tn = tag_name

      case tn
      when 'input'
        value
      when 'button'
        super
      else
        raise Exception::Error, "unknown tag name for button: #{tn}"
      end
    end

    #
    # Returns true if this element is enabled.
    #
    # @return [Boolean]
    #

    def enabled?
      !disabled?
    end

    private

    def locator_class
      ButtonLocator
    end
  end # Button

  class ButtonCollection < ElementCollection
    private

    def locator_class
      ButtonLocator
    end

    def element_class
      Button
    end
  end # ButtonsCollection
end # Watir

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.9.0 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.8.0 lib/watir-webdriver/elements/button.rb