Sha256: 05212a3e7a0ff737abf523e0b7b941663cad7f4791f3dfc231a4010771e98b4e

Contents?: true

Size: 1.24 KB

Versions: 32

Compression:

Stored size: 1.24 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

    # add the attributes from <input>
    attributes Watir::Input.typed_attributes

    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.
    #

    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

32 entries across 32 versions & 1 rubygems

Version Path
watir-webdriver-0.6.1 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.6.0 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.8 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.7 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.6 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.5 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.4 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.3 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.2 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.1 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.5.0 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.4.1 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.4.0 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.9 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.8 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.7 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.6 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.5 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.4 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.3.3 lib/watir-webdriver/elements/button.rb