title: Ruby Watir -- Trying to loop through links in cnn.com and click each one of them
body: <p>I have created this method to loop through the links in a certain div in the web site. My porpose of the method Is to collect the links insert them in an array then click each one of them.</p>
  
  <pre><code>require 'watir-webdriver'
  require 'watir-webdriver/wait'
  
  site = Watir::Browser.new :chrome
  url = "http://www.cnn.com/"
  site.goto url
  
    box = Array.new
    container = site.div(class: "column zn__column--idx-1")
    wanted_links = container.links
  
  
    box &lt;&lt; wanted_links
    wanted_links.each do |link|
      link.click
      site.goto url
      site.div(id: "nav__plain-header").wait_until_present
    end
  
  site.close
  </code></pre>
  
  <p>So far it seems like I am only able to click on the first link then I get an error message stating this:</p>
  
  <pre><code>  unable to locate element, using {:element=&gt;#&lt;Selenium::WebDriver::Element:0x634e0a5400fdfade id="0.06177683611003881-3"&gt;} (Watir::Exception::UnknownObjectException)
  </code></pre>
  
  <p>I am very new to ruby. I appreciate any help. Thank you.</p>