title: CasperJs: Clicking links in a loop to open modal popup
body: <p>I have a page that load list of items with a 'Details' link.
  Clicking this link opens a modal popup which contains the data i need.</p>
  
  <p>I want to loop through each of these 'Details' links, clicking it to open the modal popup, read the data, close it and continue to the next.</p>
  
  <p>How would i go about doing this ? Im not sure how to trigger a remote click in a loop to open the modal, followed by a '.waitForSelector' to read the info in the modal.</p>
  
  <p>So far i have:</p>
  
  <pre><code>casper.start(url);
  
  // How do i loop these two steps ??
  casper.then(function() {
      this.evaluate(function() {
          var detailsBtn = Zepto('.details').first();
          detailsBtn.trigger('click');
      });
  });
  
  casper.waitForSelector('#popup-window', function() {
      // read data from popup
  });
  </code></pre>
  
  <p>This works fine for one link :)</p>
  
  <p>Any help would be greatly appreciated !</p>
  
  <p>Thanks</p>