title: iterating over elements using Intern/Leadfoot
body: <p>There are 2 places below where code (in Javascript) is never executed although it appears as though it should.  See code below were the comment says  'THIS CODE NEVER GETS EXECUTED'.</p>
  
  <p>I happen to be in an environment where the IDs are generate dynamically.  I created the 2 files 'a.html' and 'b.html' to ultimately be added to a page (index.html) as an iframe.  I'd like to iterate through the iframes, get the ID of each iframe, and then use the ID to get the content of each iframe for testing.  </p>
  
  <p>How do I do this using the Javascript testing framework Intern?</p>
  
  <p>File: a.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;A Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Got A here
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>File: b.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;B Title&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  Got B here
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I created a file index.html that loads the files above...
  File: index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;title&gt;Main&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;iframe id="a1" width="100" height="100" src="a.html"&gt;&lt;/iframe&gt;
  &lt;iframe id="b1" width="100" height="100" src="b.html"&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>... and ran the following intern tests
  file: testFrames.js</p>
  
  <pre><code>define([
      'intern!object',
      'intern/chai!assert'
  ], function (registerSuite, assert) {
      registerSuite({
          name: 'is this working?',
  
          'Iterating through frames': function () {
              var command = this.remote;
              command = command.get(require.toUrl( "html/index.html"))
                  .findAllByTagName("iframe")
                  .then(function(iframes)
                  {
                      assert( iframes.length== 2);
                      for (var i=0;i&lt;iframes.length;i++)
                      {
                          var frame = iframes[i];
                          console.log("got frame id: ", frame.elementId);
                          frame.getAttribute("id").then(function(id)
                          {
                              // an elementId is not the same as an attribute id of an element --- ARGH!!!
                              console.log("got id: ", id);
                              command = command
                                  .findById(id)
                                  .switchToFrame(id)
                                  .getPageTitle()
                                  .then(function(text)
                                  {
                                     // THIS CODE NEVER GETS EXECUTED
                                      console.log("something should be here: ");
                                      console.log("text value: ", text);
                                      // make assertions here to verify all is well.
                                  })
                                  .end();
                              return command;
                          })
                      }
                  })
                  .end()
              ;
          return command;
          }
      });
  });
  </code></pre>