title: How to get the number of elements having same attribute in HTML in Watir?
body: <p>I have a HTML document which contains elements having the same class name.  I could just do an iteration over all the elements in a page and store with elements with a class name in a list. Is there a better way in Watir to get a count of all the HTML elements having the same class name? This question <a href="https://stackoverflow.com/questions/6397347/how-to-count-elements-with-same-attribute-value">Count of Elements with same attribute in XML</a> kind of addresses the issue, but I had two queries related to that</p>
  
  <ol>
  <li>What if the HTML document is not a strict XHTML document?</li>
  <li>What happens if different types of HTML elements have the same class?</li>
  </ol>
  
  <p>Sample HTML files could be:</p>
  
  <p>Elements of the same type having same class name</p>
  
  <pre><code>&lt;input type="password" class="foo" /&gt; 
  &lt;input type="text" class="foo" /&gt;
  </code></pre>
  
  <p>Elements of different types having same class name</p>
  
  <pre><code>&lt;input type="password" class="foo" /&gt; 
  &lt;span class="foo"&gt;&lt;/span&gt;
  &lt;a href='1' class="foo"&gt;Text&lt;/a&gt;
  </code></pre>
  
  <p>Thanks in advance, guys</p>