Selenium - NoSuchWindowException in IE 11

后端 未结 10 1902
粉色の甜心
粉色の甜心 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 07:56

    I am using IE 11 - 64 bit windows machine. This point worked for me.

    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 installations, 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 installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE.

    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.

    0 讨论(0)
  • 2020-12-05 07:58

    I found that, if the launched browser is kept on focus, you will get that exception. As soon as you launch the webdriver, open any other window, for example, you can open eclipse as soon as the script launches IE Driver. Script execution starts, and then you can open you IE Driver.. to handle it through scripts, you add the below code:

        public WebDriver driver, driver1;
        System.setProperty("webdriver.ie.driver", System.getProperty(
                        "webdriver.ie.driver", "./BrowserDrivers/IEDriverServer.exe"));
                driver = new InternetExplorerDriver(cap);
                this.driver.manage().deleteAllCookies();
                this.driver.manage().timeouts().implicitlyWait(WaitTimeConstants.WAIT_TIME_LONG, TimeUnit.SECONDS);
    
                this.driver.get("yourApplication.com");
                this.driver.manage().window().maximize();
    
    public WebDriver driver, driver1;
    System.setProperty("webdriver.ie.driver", System.getProperty(
                    "webdriver.ie.driver", "./BrowserDrivers/IEDriverServer.exe"));
            driver1 = new InternetExplorerDriver(cap);
            this.driver1.manage().deleteAllCookies();
    
            this.driver1.get("http://www.google.com");
            this.driver1.manage().window().maximize();
    
    0 讨论(0)
  • 2020-12-05 08:07

    Ignore above all... i have tried below line in my desired capabilities for IE driver then its worked .. :)

                ieCapabilities.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL,false);
    
    0 讨论(0)
  • 2020-12-05 08:12

    The solution suggested by @David Kemp is not working for the ie 11 of windows 10 - 64 bit . I have added the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet explorer\Main\FeatureControl\FEATURE_BFCACHE according to the steps mentioned For IE 11 only following https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration but after opening the https certificate page (url https://my-page:9443) it is unable to execute driver.navigate().to("javascript:document.getElementById('overridelink').click()"); throwing NoSuchWindowException

    However same works fine for ie 11 of windows 7-64 bit and able to execute the scripts .

    The work around to make ie 11 work for win 10 is by setting initialBrowserUrl capabilities to https://my-page:9443 like below

    capabilities.setCapability("initialBrowserUrl", "https://my-page:9443");
    

    but I am still confused why for ie11 / windows 10 it's different ?

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

    Below solution also works if from current page you navigate on next page on some action/event and selenium driver doesnt recognise window :-

    For 64-bit Windows installations, the key is:

     HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet explorer\Main\FeatureControl\FEATURE_BFCACHE
    

    Inside this create a DWORD value named iexplore.exe with the value of 0.

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

    IE Options --> Security Tab -> Uncheck "Enable Protected Mode" worked for me.

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