Sha256: dbacf95f387c3a7e17db83c6e688b245d570af69aacf96f26c17d19344ab2627

Contents?: true

Size: 595 Bytes

Versions: 1

Compression:

Stored size: 595 Bytes

Contents

require "webrat/core/elements/element"

module Webrat
  class SelectOption < Element #:nodoc:

    def self.xpath_search
      [".//option"]
    end

    def choose
      select.raise_error_if_disabled
      select.set(value)
    end

  protected

    def select
      SelectField.load(@session, select_element)
    end

    def select_element
      parent = @element.parent

      while parent.respond_to?(:parent)
        return parent if parent.name == 'select'
        parent = parent.parent
      end
    end

    def value
      @element["value"] || @element.inner_html
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
diabolo-webrat-0.5.1 lib/webrat/core/elements/select_option.rb