Difference between revisions of "Lapis Lazuli:Browser.find all()"

From Test Automation Wiki
Jump to: navigation, search
(Created page with "== find_all functionality == <code>browser.find_all()</code> works almost the same way as <code>browser.find()</code> except that find_all wil...")
 
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
  
 
HTML
 
HTML
<syntaxhighlight lang="html">
+
<syntaxhighlight>
 
<div class="foo">1</div>
 
<div class="foo">1</div>
 
<div class="foo" id="bar">2</div>
 
<div class="foo" id="bar">2</div>
Line 13: Line 13:
  
 
RUBY
 
RUBY
<syntaxhighlight lang="ruby">
+
<syntaxhighlight>
 
elements = browser.find_all(:class => 'foo')
 
elements = browser.find_all(:class => 'foo')
 
print elements
 
print elements

Latest revision as of 14:13, 20 June 2016

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.

Examples

HTML

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

RUBY

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"