Sha256: d99ff5ce19da9c11616ee6d7ceddc594faf4b27f464ecf7218e27d602af54bbf

Contents?: true

Size: 987 Bytes

Versions: 7

Compression:

Stored size: 987 Bytes

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

    #
    # Returns the text of the button.
    #
    # For input elements, returns the "value" attribute.
    # For button elements, returns the inner text.
    #

    def text
      assert_exists
      case @element.tag_name
      when 'input'
        value
      when 'button'
        text
      else
        raise Exception::Error, "unknown tag name for button: #{@element.tag_name}"
      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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
watir-webdriver-0.0.6 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.5 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.4 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.3 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.2 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.1 lib/watir-webdriver/elements/button.rb
watir-webdriver-0.0.1.dev7 lib/watir-webdriver/elements/button.rb