def [](value)
      if value.is_a?(Range)
        to_a[value]
      elsif @selector.key? :adjacent
        to_a[value] || element_class.new(@query_scope, invalid_locator: true)
      elsif @to_a && @to_a[value]
        @to_a[value]
      else
        element_class.new(@query_scope, @selector.merge(index: value))
      end
    end
def [](value)
      if value.is_a?(Range)
        to_a[value]
      elsif @selector.key? :adjacent
        to_a[value] || element_class.new(@query_scope, invalid_locator: true)
      elsif @to_a && @to_a[value]
        @to_a[value]
      else
        element_class.new(@query_scope, @selector.merge(index: value))
      end
    end
Get the element at the given index or range.

 Any call to an ElementCollection that includes an adjacent selector
 can not be lazy loaded because it must store the correct type

 Ranges can not be lazy loaded

 @param [Integer, Range] value Index (0-based) or Range of desired element(s)
 @return [Watir::Element, Watir::ElementCollection] Returns an instance of a Watir::Element subclass