Selenium: org.openqa.selenium.NoSuchWindowException: Currently focused window has been closed

I have been struggling with the same problem since yesterday and finally got my test to work.
Check if you have all the required configurations for the InternetExplorerDriver. For me it was the protected mode settings which I finally tested even though I am on Win 10.
Hope it helps you, too.


There are 2 ways:

Way 1: Setting INITIAL_BROWSER_URL:

File ieFile = new File("D:\\IEDriverServer_x64_2.53.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", ieFile.getAbsolutePath());
DesiredCapabilities ieCaps = DesiredCapabilities.internetExplorer();
ieCaps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, "http://www.bing.com/");
driver = new InternetExplorerDriver(ieCaps);
//some operations on that site
driver.findElement(By.id("sb_form_q")).clear();
driver.findElement(By.id("sb_form_q")).sendKeys("Ripon Al Wasim");
driver.findElement(By.id("sb_form_go")).click();

Way 2: To set a registry entry on the target computer: For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates.

For 32-bit Windows: The key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

For 64-bit Windows: The key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

Note: Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

enter image description here

For more details you can visit: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration


There are three Settings :

  1. Zoom level set to 100%
  2. Unchecked the Internet Options --> Security--> For Internet and Trusted sites
  3. Unchecked "Enable Protected Mode"

Tags:

Selenium