title: How to switch control from child window to parent window in selenium webdriver?
body: <ul>
  <li>From Parent window I'm passing the control to child window</li>
  <li>I'm performing actions in the child window</li>
  <li>After performing, from a child window one more window will open(Child
  of 1st child window).</li>
  <li><p>I have to close both the child windows and have to get back to the
  Parent window.</p>
  
  <p>I'm not able to switch the control from child to parent window. I have tried out the below code</p>
  
  <pre><code> String winHandleBefore = _driver.getWindowHandle();
  for(String winHandle : _driver.getWindowHandles()){
      _driver.switchTo().window(winHandle);
  }
  
  String winHandleAfter = _driver.getWindowHandle();
  </code></pre>
  
  <p>/<em>performing actions in the child window</em>/</p>
  
  <pre><code>driver.close();
  _driver.switchTo().window(winHandleBefore);
  </code></pre></li>
  </ul>