Sha256: b457a6f4b70ccf415f948397199949467e55ad53085198f8713b87740f058c18

Contents?: true

Size: 841 Bytes

Versions: 20

Compression:

Stored size: 841 Bytes

Contents

module Watir
  module List
    include Enumerable

    #
    # Yields each LI associated with this list.
    #
    # @example
    #   list = browser.ol
    #   list.each do |li|
    #     puts li.text
    #   end
    #
    # @yieldparam [Watir::LI] element Iterate through the items for this List.
    #

    def each(&block)
      list_items.each(&block)
    end

    alias length count
    alias size count
    alias items count
    alias empty? none?

    #
    # Returns item from this list at given index.
    #
    # @param [Integer] idx
    # @return Watir::LI
    #

    def [](idx)
      list_items[idx]
    end

    def list_items
      LICollection.new(self, adjacent: :child, tag_name: 'li')
    end
  end # List

  class OList < HTMLElement
    include List
  end

  class UList < HTMLElement
    include List
  end
end # Watir

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
watir-7.1.0 lib/watir/elements/list.rb
watir-7.0.0 lib/watir/elements/list.rb
watir-7.0.0.beta5 lib/watir/elements/list.rb
watir-7.0.0.beta4 lib/watir/elements/list.rb
watir-7.0.0.beta3 lib/watir/elements/list.rb
watir-7.0.0.beta2 lib/watir/elements/list.rb
watir-7.0.0.beta1 lib/watir/elements/list.rb
watir-6.19.1 lib/watir/elements/list.rb
watir-6.19.0 lib/watir/elements/list.rb
watir-6.18.0 lib/watir/elements/list.rb
watir-6.17.0 lib/watir/elements/list.rb
watir-6.16.5 lib/watir/elements/list.rb
watir-6.16.4 lib/watir/elements/list.rb
watir-6.16.3 lib/watir/elements/list.rb
watir-6.16.2 lib/watir/elements/list.rb
watir-6.16.1 lib/watir/elements/list.rb
watir-6.16.0 lib/watir/elements/list.rb
watir-6.15.1 lib/watir/elements/list.rb
watir-6.15.0 lib/watir/elements/list.rb
watir-6.14.0 lib/watir/elements/list.rb