Lapis Lazuli:Browser.find all()

From Test Automation Wiki
Jump to: navigation, search

find_all functionality

browser.find_all() works almost the same way as browser.find() except that find_all will return an array / collection of all the elements that match your condition.



<div class="foo">1</div>
<div class="foo" id="bar">2</div>
<div class="fox" id="jump">3</div>


elements = browser.find_all(:class => 'foo')
print elements
 => array(0 => ::WatirElement::, 1 => ::WatirElement::)

print elements[0].text
 => "1"

print elements[1].id
 => "bar"

collection = browser.find_all(:div)
print browser.pick_one(:last. collection).id
 => "jump"