We started a new Selenium environment with Selenium 3.4, using a grid configuration with a Linux-based hub and a Windows Server-based node. InternetExplorerDriver
started throwing NoSuchWindowException
when run remotely. I got the following output:
org.openqa.selenium.support.ui.ExpectedConditions findElement
WARNING: WebDriverException thrown by findElement(By.xpath: //h2[starts-with(@class, 'headline')])
org.openqa.selenium.NoSuchWindowException: Unable to find elements on closed window (WARNING: The server did not provide any stacktrace information)
[many more stack trace lines]
Caused by: org.openqa.selenium.remote.ScreenshotException: Screen shot has been taken
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
... 43 more
Ultimately it repeats the NoSuchWindowException
over and over afterward.
We're running IE 11, so I ensured that Enhanced Protected Mode was disabled, the proper registry key fixes had been applied, and so on as described at SeleniumHQ (https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration), as well as many answers here on StackOverflow. Chrome works fine, Firefox works fine, IE even works fine as long as it is run locally. I can't find any more information on this.
How do I stop this exception from occurring?
For us, it was a matter of the Windows Server running the node (we had been running it on a Windows 7 machine previously). The node had to be run as an administrator. We ultimately created a shortcut and set it to be run as an administrator through the Shortcut tab -> Advanced button.