Casperjs access a frame within a frame
<p>I'm using CasperJS to script a webpage that layers framesets with 2 subframes multiple times (goes to 3 layers deep in some cases). The website is some form a old version of an online email client. I'm trying to check if there are any new messages, and if there are, download any attachments.</p>

<p>The format of each page is always: first frame stores the login credentials, and the second frame contains actual content.</p>

<p>I have two needs: use a waitForSelector call to find out when the page is fully loaded, which is always multiple layers deep, and do clicks at the deepest node to find the email message. </p>

<p>How do I access selectors that are multiple frames deep? CasperJS makes it trivially easy to do one, but I haven't been able to get my script to reach multiple layers down.</p>

<p>I've tried using window object, but the CasperJS selector has been throwing errors.</p>

<pre><code>casper.waitForSelector(window.frames[1].document.getElementById('frame[name = Frame_A ]'), {
   // when loaded do this
});
</code></pre>