Module: Watir::Adjacent
- Included in:
- Element
- Defined in:
- lib/watir/adjacent.rb
Instance Method Summary collapse
- 
  
    
      #child(opt = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns element of direct child of current element. 
- 
  
    
      #children(opt = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns collection of elements of direct children of current element. 
- 
  
    
      #following_sibling(opt = {})  ⇒ Object 
    
    
      (also: #next_sibling)
    
  
  
  
  
  
  
  
  
  
    Returns following sibling element of current element. 
- 
  
    
      #following_siblings(opt = {})  ⇒ Object 
    
    
      (also: #next_siblings)
    
  
  
  
  
  
  
  
  
  
    Returns collection of following sibling elements of current element. 
- 
  
    
      #parent(opt = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns parent element of current element. 
- 
  
    
      #preceding_sibling(opt = {})  ⇒ Object 
    
    
      (also: #previous_sibling)
    
  
  
  
  
  
  
  
  
  
    Returns preceding sibling element of current element. 
- 
  
    
      #preceding_siblings(opt = {})  ⇒ Object 
    
    
      (also: #previous_siblings)
    
  
  
  
  
  
  
  
  
  
    Returns collection of preceding sibling elements of current element. 
- 
  
    
      #siblings(opt = {})  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Returns collection of siblings of current element, including current element. 
Instance Method Details
#child(opt = {}) ⇒ Object
Returns element of direct child of current element.
| 94 95 96 | # File 'lib/watir/adjacent.rb', line 94 def child(opt = {}) xpath_adjacent(opt.merge(adjacent: :child, plural: false)) end | 
#children(opt = {}) ⇒ Object
Returns collection of elements of direct children of current element.
| 107 108 109 110 111 | # File 'lib/watir/adjacent.rb', line 107 def children(opt = {}) raise ArgumentError, '#children can not take an index value' if opt[:index] xpath_adjacent(opt.merge(adjacent: :child, plural: true)) end | 
#following_sibling(opt = {}) ⇒ Object Also known as: next_sibling
Returns following sibling element of current element.
| 54 55 56 | # File 'lib/watir/adjacent.rb', line 54 def following_sibling(opt = {}) xpath_adjacent(opt.merge(adjacent: :following, plural: false)) end | 
#following_siblings(opt = {}) ⇒ Object Also known as: next_siblings
Returns collection of following sibling elements of current element.
| 67 68 69 70 71 | # File 'lib/watir/adjacent.rb', line 67 def following_siblings(opt = {}) raise ArgumentError, '#next_siblings can not take an index value' if opt[:index] xpath_adjacent(opt.merge(adjacent: :following, plural: true)) end | 
#parent(opt = {}) ⇒ Object
Returns parent element of current element.
| 13 14 15 | # File 'lib/watir/adjacent.rb', line 13 def parent(opt = {}) xpath_adjacent(opt.merge(adjacent: :ancestor, plural: false)) end | 
#preceding_sibling(opt = {}) ⇒ Object Also known as: previous_sibling
Returns preceding sibling element of current element.
| 25 26 27 | # File 'lib/watir/adjacent.rb', line 25 def preceding_sibling(opt = {}) xpath_adjacent(opt.merge(adjacent: :preceding, plural: false)) end | 
#preceding_siblings(opt = {}) ⇒ Object Also known as: previous_siblings
Returns collection of preceding sibling elements of current element.
| 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 | 
#siblings(opt = {}) ⇒ Object
Returns collection of siblings of current element, including current element.
| 82 83 84 | # File 'lib/watir/adjacent.rb', line 82 def siblings(opt = {}) parent.children(opt) end |