Method: Watir::Adjacent#preceding_siblings

Defined in:
lib/watir/adjacent.rb

#preceding_siblings(opt = {}) ⇒ Object Also known as: previous_siblings

Returns collection of preceding sibling elements of current element.

Examples:

browser.text_field(name: "new_user_first_name").preceding_siblings.size
#=> 3

Raises:

  • (ArgumentError)


38
39
40
41
42
# File 'lib/watir/adjacent.rb', line 38

def preceding_siblings(opt = {})
  raise ArgumentError, '#previous_siblings can not take an index value' if opt[:index]

  xpath_adjacent(opt.merge(adjacent: :preceding, plural: true))
end