Selenium - NoSuchWindowException in IE 11

后端 未结 10 1903
粉色の甜心
粉色の甜心 2020-12-05 07:54

I am trying to automate a webpage using selenium in IE11. I have set the protected mode settings to same level and zoom level is 100%. While running the test it opens the we

相关标签:
10条回答
  • 2020-12-05 08:14

    Added domain of AUT to list of "Trusted Sites" for i.e. in "Internet Options". Solved the problem.

    0 讨论(0)
  • 2020-12-05 08:16

    You can follow a few options from below:

    1. Use relative paths in the project, later you can choose to get its absolute path.
    2. Setting the Protected mode setting for all, to either enabled or disabled.
    3. Try understanding what really this exception mean "org.openqa.selenium.NoSuchWindowException: Unable to find element on closed window (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 18 milliseconds"

    This states that whatever being done by your code (the web driver) is not able to identify the window of IE.

    The possible causes can be: a. Multiple driver instances are already running which were instantiated by older runs and could not have been terminated by quite(). b. The sometimes when you use close() on a driver it will not terminate the IE Driver, so use quite() after closing inside a finally block. Yes, add some Exception handling to avoid the above issue.

    1. Exception "org.openqa.selenium.NoSuchWindowException" also suggests that web driver instance is not able to get the handle of IE's window tab. I faced this issue when accidentally, the browser was closed and the code was still trying to locate and do some action on a web element. In this case, the driver throws this exception to tell that there is no IE browser opened at all.

    2. Having a check on the opening of browser can also help, I usually keep some piece of code that gives logs of used Driver object and the port where it is trying to connect and to which browser to.

    For me, point 4 & 5 worked. but you might wanna just change the web driver's service i.e. browser. IE is just too slow sometimes to honour the selenium API calls :(

    0 讨论(0)
  • 2020-12-05 08:19

    First of all, don't use

    capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
    

    as you have already set Protected mode settings. For the issue you are seeing, it should be because of the missing registry settings that is added as a prerequisite for running tests in IE11:

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

    0 讨论(0)
  • 2020-12-05 08:21

    Add http://localhost/ to your trusted sites in IE11. This worked for me,after trying everything else without results.

    0 讨论(0)
提交回复
热议问题