title: How to switch control from a second window to the third window in selenium
body: <p>Actually , in my website i am having around 7,8 windows . I have switched control from window 1 to window 2 through window handler . But now how to switch control from second to third , third to fourth and so on . </p>
  
  <p>Please help me in this situation . I used the following code to switch control from first window to second , but the same code is not working for second to third , third to fourth and so on :-</p>
  
  <p>String window1 = driver.getWindowHandle();</p>
  
  <pre><code>for (String window2 : driver.getWindowHandles()) {
      driver.switchTo().window(window2); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
  }
  </code></pre>