Sha256: 7600bb097da8bf2f9844c223680b28bd6dd217e8b39902ac841319f0b30deeea

Contents?: true

Size: 831 Bytes

Versions: 2

Compression:

Stored size: 831 Bytes

Contents

# encoding: utf-8
module Watir

  #
  # Represents an option in a select list.
  #

  class Option < HTMLElement

    #
    # Select this option
    #

    def select
      assert_exists
      @element.select
    end

    #
    # Toggle the selected state of this option
    #

    def toggle
      assert_exists
      @element.toggle
    end

    #
    # Is this option selected?
    #

    def selected?
      assert_exists
      @element.selected?
    end

    def text
      assert_exists

      # A little unintuitive - we'll return the 'label' or 'text' attribute if
      # they exist, otherwise the inner text of the element

      attribute = [:label, :text].find { |a| attribute? a }

      if attribute
        @element.attribute(attribute)
      else
        @element.text
      end
    end

  end # Option
end # Watir

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
watir-webdriver-0.0.1.dev6 lib/watir-webdriver/elements/option.rb
watir-webdriver-0.0.1.dev5 lib/watir-webdriver/elements/option.rb