Module: Watir::List

Includes:
Enumerable
Included in:
OList, UList
Defined in:
lib/watir/elements/list.rb

Instance Method Summary collapse

Instance Method Details

#[](idx) ⇒ Object

Returns item from this list at given index.

Parameters:

  • idx (Integer)

Returns:

  • Watir::LI



35
36
37
# File 'lib/watir/elements/list.rb', line 35

def [](idx)
  list_items[idx]
end

#each {|element| ... } ⇒ Object

Yields each LI associated with this list.

Examples:

list = browser.ol
list.each do |li|
  puts li.text
end

Yield Parameters:

  • element (Watir::LI)

    Iterate through the items for this List.



19
20
21
# File 'lib/watir/elements/list.rb', line 19

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

#list_itemsObject



39
40
41
# File 'lib/watir/elements/list.rb', line 39

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