title: selenium web driver - switch to parent window
body: <p>I use selenium Web Driver. I have opened a parent window. After I click on the link the new window opens. I choose some value from the list and this window automatically closes. Now I need to operate in my parent window. How can I do this? I tried the following code:</p>
  
  <pre><code>String HandleBefore = driver.getWindowHandle();
  driver.findElement(By.xpath("...")).click();
   for (String Handle : driver.getWindowHandles()) {
          driver.switchTo().window(Handle);}
   driver.findElement(By.linkText("...")).click();
   driver.switchTo().window(HandleBefore);
  </code></pre>
  
  <p>This does not work though. </p>