Class: Watir::HTMLElements

Inherits:
ElementCollections show all
Includes:
CommonCollection
Defined in:
lib/watir/collections.rb

Instance Method Summary collapse

Methods inherited from ElementCollections

#[], #first, #get_length_of_input_objects, #inspect, #last, #show, #to_s

Constructor Details

#initialize(container, how, what) ⇒ HTMLElements

Returns a new instance of HTMLElements.



381
382
383
384
385
386
387
388
389
# File 'lib/watir/collections.rb', line 381

def initialize(container, how, what)
  @how = how
  @what = what
  if how == :index
    raise MissingWayOfFindingObjectException,
                "#{self.class} does not support attribute #{@how}"
  end
  super(container)
end

Instance Method Details

#eachObject



398
399
400
# File 'lib/watir/collections.rb', line 398

def each
  @container.locate_all_elements(@how, @what).each { |element| yield element }
end

#element_classObject



378
# File 'lib/watir/collections.rb', line 378

def element_class; HTMLElement; end

#element_tagObject



379
# File 'lib/watir/collections.rb', line 379

def element_tag; '*'; end

#iterator_object(i) ⇒ Object



402
403
404
405
# File 'lib/watir/collections.rb', line 402

def iterator_object(i)
  count = 0
  each {|e|  return e if count == i;count += 1;}
end

#lengthObject Also known as: size



391
392
393
394
395
# File 'lib/watir/collections.rb', line 391

def length
  count = 0
  each {|element| count += 1 }
  count
end