NoSuchWindowException - Cannot find element in closed window in Selenium on IE, even though after consulting the configuration in other answers

This is related to my other recent Selenium question (this question was about a Firefox related issue, this issue is related to an IE specific issue).

Basically when I ran the following code

ieDriver.Navigate().GoToUrl("http://localhost:51282");
IWebElement linkToAboutPage = ieDriver.FindElement(By.Id("test"));
linkToAboutPage.Click();

      

to simulate a click on a link, it navigates to the page successfully, but when it tries to get the actual element, I get the following exception:

An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll but was not handled in user code

Additional information: Unable to find element on closed window

The accepted answer to this question suggests that "Enable Protected Mode" in IE's security settings should be either selected or all unselected. Indeed, when I look at these settings, "Enable Protected Mode" is not selected for intranet but not for others: enter image description here

Unfortunately, as the screenshot shows, this is managed by my corporate IT department and I'm not sure if I can convince them that I can change the settings. I was also unable to edit my registry as per some of the other answers (presumably due to lack of administrative rights).

Some of the other solutions I've seen involve installing IntroduceInstabilityByIgnoringProtectedModeSettings

in true

, providing, InitialBrowserUrl

or customizing EnsureCleanSession

- true

. As shown below, I am currently doing all these things:

var ieOptions = new InternetExplorerOptions()
{
    InitialBrowserUrl = "http://www.google.com",
    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
    IgnoreZoomLevel = true,
    EnableNativeEvents = true,
    EnsureCleanSession = true
};

ieDriver = new InternetExplorerDriver(ieOptions);
ieDriver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 0, 10);

      

However, I still have the same problem.

Is there anything else I can try that is not related to the fact that I was looking for corporate IT solutions for policy exceptions?

Perhaps this only happens when I run on localhost

(which is a problem, because that's where I intend to do most of my testing).

+3


source to share


1 answer


I found that setting the InitialBrowserUrl

source url you want to navigate to paired with IntroduceInstabilityByIgnoringProtectedModeSettings = true

works for me.

var ieOptions = new InternetExplorerOptions()
{
    InitialBrowserUrl = <your-starting-url>
    IntroduceInstabilityByIgnoringProtectedModeSettings = true,
    ...
};

      

Unfortunately, I have no reason why this works, so this "fix" might just be anecdotal ...




Here are some other solutions you can try (from the official help):

Required configuration

  • The IEDriverServer exectuable must be loaded and placed in the PATH .
  • In IE 7 or higher on Windows Vista or Windows 7, you must set the "Protected Mode" setting for each zone to the same value. The value can be turned on or off if it is the same for each zone. To set Protected Mode options, select "Internet Options ..." from the "Tools" menu and go to the "Security" tab. A check box will be selected for each zone at the bottom of the tab labeled "Enable Protected Mode".
  • Also, for IE 10 and above, "Enhanced Protected Mode" must be disabled. This option is on the Advanced tab of the Internet Options dialog box.
  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.
  • For IE 11 only, you will need to set a registry entry on the target computer in order for the driver to maintain a connection to the instance of Internet Explorer it creates. For 32-bit Windows installations, the key you must check in Registry Editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

    . To install 64-bit versions of Windows, the key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE

    . Note that a subkey FEATURE_BFCACHE

    may or may not be present and must be created if it is missing. Important: Inside this key, create a DWORD value named iexplore.exe

    with value 0.

Link:

https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration

+3


source







All Articles