title: Loop through links on a page in Codeception Tests
body: <p>I'm writing some functionality tests using Codeception and the PHPBrowser webdriver. </p>
  
  <p>Codeception uses specific references in CSS or XPath to check elements on a page.</p>
  
  <p>But I want to be able to loop through all the links in my menu, click on it and run a test to see if the link is working. </p>
  
  <p>ie. if my menu looks like this: </p>
  
  <pre><code>&lt;ul id='nav'&gt;
  &lt;li&gt;&lt;a&gt;Link1&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Link2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Link3&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Link4&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a&gt;Link5&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I want to be able to loop through the links and pass its index:</p>
  
  <pre><code>$links = somefunctiontogetalllinks();
  for ($x = 0; $x &lt;= count($links); $x++) {
     codeceptionTest($x);
  } 
  </code></pre>
  
  <p>And then the test can refer to the link using CSS pseudo selectors: </p>
  
  <pre><code>public function codeceptionTest($index) {
     $i-&gt;click('#nav &gt; li:nth-child(' . $index . ') &gt; a');
     $I-&gt;see('Page Content');
  }
  </code></pre>
  
  <p>I can;t find any way to get a collection of elements using PHPbrowser or Codeception methods, and I'm unsure whether either presents the page it scrapes as an object to traverse. </p>