title: When and how to use switchTo() method in webDriver (Selenium 2) to handle window/pop up
body: <p>I am having trouble clicking or interacting with some page elements. They seem like normal DOM objects.  just buttons here is the code for one</p>
  
  <pre><code>&lt;div style="clear: both; text-align: right"&gt;
   &lt;img id="nextstep" class="nextbtn" height="21" alt="" src="/edit/images/author/next.png"&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>After clicking a button as "Upload file" another pop up window was opened. My task is to upload a file at pop up window and back to original window. I'll try to explain</p>
  
  <p>I start a webDriver for</p>
  
  <p>www.test.com   (&lt;- made up name for example)</p>
  
  <p>I login</p>
  
  <p>click upload a file button</p>
  
  <p>After this click our site redirects to www.foo.com instead of the above I am using the same driver created earlier and I try to interact with the buttons on the post upload page</p>
  
  <p>button.click()</p>
  
  <p>It never finds these buttons but they are there in firebug and appear normal.</p>