title: Selenium: unable to switch window
body: <p>I am trying to switch to another pop-up window,but is giving some sort of error. I am not able to figure out why the code in not working for switching the window</p>
  
  <p>Error it is giving is</p>
  
  <p><em>java.lang.NullPointerException: null value in entry: name=null</em></p>
  
  <p>Here is the code....</p>
  
  <pre><code>String parentWindowHandle = driver.getWindowHandle();
          System.out.println("parentWindowHandle......"+parentWindowHandle);
          //click on "register"
  
          Actions act = new Actions(driver);
              act.click(driver.findElement(By.id("ctl00_ContentPlaceHolder1_btnRegisterMe")));
          act.perform();
  
          sleep(26000); 
          String popUpWindowHandle=null;
          Set&lt;String&gt; openWindowsList = driver.getWindowHandles();
          for (String windowHandle : openWindowsList) {
               System.out.println("windowHandle......"+windowHandle);
              if (!windowHandle.equals(parentWindowHandle))
                  {popUpWindowHandle = windowHandle;
  
                break;}
          }                                                
                  // Switching control to newly opened window
  
          driver.switchTo().window(popUpWindowHandle);
  </code></pre>