```
String Parentwindow = driver.getWindowHandle();

driver.findElement(By.xpath("//*[@id='ImageButton5']")).click();
Thread.sleep(3000);

for(String winHandle : driver.getWindowHandles())
{
    driver.switchTo().window(winHandle);
    Thread.sleep(3000);
}
System.out.println("Title of the page after - switchingTo: " + driver.getTitle());

driver.findElement(By.id("txtEnterCptCode")).sendKeys("99219");
//Thread.sleep(3000);
driver.findElement(By.id("btnSearch")).click();

```

I am using this code for switching to new window. but it shows error as:

```
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with id == txtEnterCptCode (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 351 milliseconds

```

any one help me out of this please.