Sha256: 3dd10a9f20a70fdb774ff8ec6895b8f85d579d1a7d8de5e658b87215107b65ba

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

module PageObject
  module Elements
    class UnorderedList < Element
      include Enumerable

      #
      # iterator that yields with a PageObject::Elements::ListItem
      #
      # @return [PageObject::Elements::ListItem]
      #
      def each
        for index in 1..self.items do
          yield self[index-1]
        end
      end

      #
      # Return the PageObject::Elements::ListItem for the index provided.  Index
      # is zero based.
      #
      # @return [PageObject::Elements::ListItem]
      #
      def [](idx)
        Object::PageObject::Elements::ListItem.new(children[idx], :platform => :watir)
      end

      #
      # Return the number of items contained in the unordered list
      #
      def items
        children.size
      end

      #
      # Return the ListItem objects that are children of the
      # UnorderedList
      #
      def list_items
        children.collect do |obj|
          Object::PageObject::Elements::ListItem.new(obj, :platform => :watir)
        end
      end

      protected

      def child_xpath
        "./child::li"
      end

      def self.watir_finders
        [:class, :id, :index, :xpath]
      end

      def children
        element.uls(:xpath => child_xpath)
      end

    end

    ::PageObject::Elements.tag_to_class[:ul] = ::PageObject::Elements::UnorderedList
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page-object-2.1.1 lib/page-object/elements/unordered_list.rb
page-object-2.1 lib/page-object/elements/unordered_list.rb