Sha256: c9318c2abd9933d6fb7014d67072d1f29495879d341735f15ef1cb640b5d70d0

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# encoding: utf-8
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
      assert_exists

      tn = @element.tag_name.downcase

      case tn
      when 'input'
        @element.attribute(:value)
      when 'button'
        @element.text
      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 locate
      @parent.assert_exists
      ButtonLocator.new(@parent.wd, @selector, self.class.attribute_list).locate
    end

  end # Button

  class ButtonCollection < ElementCollection
    private

    def locator_class
      ButtonLocator
    end

    def element_class
      Button
    end
  end # ButtonsCollection
end # Watir

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
watir-webdriver-0.6.10 lib/watir-webdriver/elements/button.rb