title: How do I click on a link without id
body: <p>I'm not experienced in javascript. I'm trying to write a function in CasperJS, which uses javascript.</p>
  
  <p>I'm trying to click on a link from a search result page. The <code>&lt;a href&gt;</code> tag does not have an id to it, but it is enclosed in a <code>&lt;h3 /&gt;</code>, which is enclosed in a <code>&lt;div  id="some_id"/&gt;</code>.</p>
  
  <p>Essentially the code looks like this:</p>
  
  <pre><code>&lt;div id="result_0"&gt;
      &lt;div /&gt;
      &lt;div /&gt;
      &lt;h3 class="..."&gt;
          &lt;a href="some_link"&gt;
          .
          .
          &lt;/a&gt;
      &lt;/h3&gt;
  .
  .
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to know how to click that link in javascript.</p>
  
  <p>I tried doing it like this:</p>
  
  <pre><code>document.getElementById('result_0').getElementsByTagName('div')[2].getElementsByTagName('a')[1].click();
  </code></pre>
  
  <p>But this doesn't seem to work. Can you guys help ?</p>
  
  <p>Edit: Here is the link to my entire script: <a href="https://github.com/ctrl-shift-esc/randomamazonshopper/blob/master/myscript.js" rel="nofollow">https://github.com/ctrl-shift-esc/randomamazonshopper/blob/master/myscript.js</a></p>