title: How to select a href link randomly | Watir
body: <p>Using the following HTML I am trying to randomly select one of the href links</p>
  
  <pre><code>&lt;div class="field"&gt;
  &lt;a href="/destinations/caribbean/british-virgin-islands/tortola-power-charter/availability"&gt;Check availability&lt;/a&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/article&gt;
  &lt;/div&gt;
  &lt;div class="views-row views-row-3 views-row-odd views-row-last"&gt;
  &lt;article id="node-cruise-47" class="node node-cruise node-search-result node-cruise-search-result node-published node-not-promoted node-not-sticky author-admin odd clearfix s-search-result" itemscope="" itemtype="http://schema.org/Product"&gt;
  &lt;div class="search-result-inner clearfix"&gt;
  &lt;div class="s-search-result--left"&gt;
  &lt;div class="s-search-result--middle"&gt;
  &lt;div class="s-search-result--right"&gt;
  &lt;div class="field field-name-field-price field-type-number-decimal field-label-inline clearfix price-summary"&gt;
  &lt;div class="field field-name-field-departure-duration field-type-number-integer field-label-hidden price-conditions primary-condition"&gt;Based on 7 nights, yacht only&lt;/div&gt;
  &lt;div class="availability-button-wrapper-search"&gt;
  &lt;div class="field"&gt;
  &lt;a href="/destinations/caribbean/british-virgin-islands/tortola-crewed-charter/availability"&gt;Check availability&lt;/a&gt;
  </code></pre>
  
  <p>Note that several href links are present on the page not just these 2. I am using the following code </p>
  
  <pre><code>b.links(:xpath =&gt; '//div[@class="field"]/a').click 
  </code></pre>
  
  <p>However I get:</p>
  
  <pre><code>"undefined method `click' for #&lt;Watir::AnchorCollection:0x2ba1858&gt; (NoMethodError)"
  </code></pre>