title: Cannot switch to new window using Selenium Webdriver using switchTo()
body: <p>I have searched and searched for an answer to this question. I am testing in IE8 using Selenium Webdriver and C#. At a certain point in the test I am required to click a button that will then open up a new application window with forms that need to be filled out to continue the test. </p>
  
  <p>I have tried:</p>
  
  <pre><code>driver.switchTo().Window(driver.WindowHandles[0]);
  driver.switchTo().Window(driver.WindowHandles[1]); //this one usually returns and error
  driver.switchTo().Window(driver.WindowHandles.Last());
  </code></pre>
  
  <p>I have also tried </p>
  
  <pre><code>foreach(String handle in driver.WindowHandles)
  {
       driver.switchTo().Window(handle);
       //do things here
  }
  </code></pre>
  
  <p>Each one fails and when I write the handle name to the console the outputs are all the same window name no matter what I try to do. Does anyone have an idea as to how I can get the new window?</p>
  
  <p>Adding on to question:</p>
  
  <p>Thank you @Saifur for the new direction with using PopupWindowFinder.</p>
  
  <p>This is what I have tried with it so far</p>
  
  <pre><code>string currentWindow = driver.CurrentWindowHandle;
  PopupWindowFinder finder = new PopupWindowFinder(driver);
  string popWindow = finder.Click(driver.FindElementById("Element"));
  driver.SwitchTo().Window(popWindow);
  </code></pre>
  
  <p>So this is supposed to click on the element that will begin the popup event and then the switch should place it on the popup window so I can continue the test. Here is the problem now. When the <code>Element</code> is clicked by <code>finder</code> the app I am testing on creates one popup, then that popup window is closed, then another popup appears then that is closed and finally the actual app I need to test on appears and is either the current focus on the monitor or behind the initial page that started all of this. </p>
  
  <p>So How can I get to the app window I need to test on? I have tried to switch onto the different popup windows that appear to try and jump it to the app window, but that did not work. Thanks in advance</p>