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


33
34
35
# File 'lib/watir/elements/list.rb', line 33

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.


17
18
19
# File 'lib/watir/elements/list.rb', line 17

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

#list_itemsObject


37
38
39
# File 'lib/watir/elements/list.rb', line 37

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