title: Frame navigation in Selenium
body: <p>I have been using Selenium (Webdriver 2.32, with Perl bindings Selenium::Remote::Driver 0.16) to successfully navigate a frame-based application "F":</p>
  
  <pre><code>&lt;frameset rows=35,*&gt;  // divide page two rows, 35px and remainder high
      &lt;frame name="Header"&gt;  // top row is Header
      &lt;frameset cols=182,*&gt;  // divide second row into two columns, 182px and remainder wide
          &lt;frame name="TOC"&gt;  // left column is TOC
          &lt;frameset rows=*,0,0&gt;  // right column two hidden rows
              &lt;frame name="Main"&gt;  // (top) row is Main content
              &lt;frame name="HiddenFrame"&gt;  // hidden stuff
              &lt;frame name="UploadFrame"&gt;  // hidden stuff
  </code></pre>
  
  <p>When first entering a page, I call <code>$drv-&gt;switch_to_frame(); $drv-&gt;switch_to_frame('TOC');</code> to go to the Table of Contents, where I click a link that reloads the Main content. Then I call <code>$drv-&gt;switch_to_frame(); $drv-&gt;switch_to_frame('Main');</code> where I can then do stuff in the Main content.</p>
  
  <p>Now I need to navigate a slightly different page "H", but it's not working:</p>
  
  <pre><code>&lt;frameset rows=115,*&gt;  // divide page two rows, 115px and remainder high
      &lt;frame name="Header"&gt;  // top row is Header
      &lt;frameset cols=180,*&gt;  // divide second row into two columns, 180px and remainder wide
          &lt;frameset rows=0,*&gt;  // hidden row and remainder of column
              &lt;frame name="DataChannelFrame"&gt;  // hidden stuff
              &lt;frame name="TOC"&gt;  // left column is TOC
          &lt;frame name="Main"&gt;  // (top) row is Main content
  </code></pre>
  
  <p>In this case, Selenium is failing to find anything in the TOC to click on, whether or not I use the same navigation as before. I suspect that I'm not actually <em>in</em> the TOC, but I have no idea where I am. Needless to say, it's not going into the Main section either.</p>
  
  <p>Question 1: On these two pages, <em>where</em> is Selenium starting out at? Which frame is it in? Is it something I can count on (documented and consistent)? I found my way around "F" by trial and error, but it's not working in "H".</p>
  
  <p>Question 2: When I do a <code>$drv-&gt;switch_to_frame();</code>, how far "up" does it go? What is considered the "parent" of the current frame? Is it always a frameset? I tried <code>$drv-&gt;switch_to_frame("relative=top");</code> instead of (), and it didn't work on either "F" or "H".</p>
  
  <p>Question 3: When I switch to a named frame, does it have to be on the child level from where I am, or is it at any depth below me? If it has to be a child, maybe "relative=top" put me too high in the tree?</p>
  
  <p>Question 4: When I'm in Main ("F" application), I can successfully get to the TOC with the above navigation (up one, down to named frame). How come that works when presumably a frameset (sibling to TOC) is Main's parent?</p>
  
  <hr>
  
  <h2>Update</h2>
  
  <p>Arrrrgh! Who would have dreamed that some page coder would have used <code>&lt;b&gt;</code> tags with "onClick" rather than styling an <code>&lt;a&gt;</code> tag? So it <em>was</em> getting to the desired frame, but the links I was was looking for weren't quite there.</p>
  
  <p>Nevertheless, even though I have it working now (thanks anyway, those who responded), I'm still curious what the formal definitions of switch_to_frame() and switch_to_frame('name') are. Does () go all the way to the "top", or just up a level (it seems to be going all the way to the top/default), and does ('name') go down any number of levels until it finds the named frame? (it seems to be). So () followed by ('name') should get me to any uniquely named frame?</p>